Skip to content

Commit ee0ddb4

Browse files
V1.0.2 (#87)
* Bugfix: added $commit to Transaction::__invoke (issue #86) * Bugfix: added null coalescing to VeloxException throw (issue #85) * Bugfix: fixed positional parameter handling (issue #84)
1 parent 253c7ec commit ee0ddb4

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/Database/Procedures/PreparedStatement.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ public function addParameterSet(array $paramArray, string $prefix = '') : void {
6969
if (!is_scalar($value) && !is_null($value)){
7070
throw new VeloxException("Value for :".$key." is not a scalar or null.",50);
7171
}
72-
$paramArray[":".$prefix.$key] = $value;
73-
unset($paramArray[$key]);
72+
if (filter_var($key, FILTER_VALIDATE_INT) === false) {
73+
$paramArray[":" . $prefix . $key] = $value;
74+
unset($paramArray[$key]);
75+
}
7476
}
7577
$this->_paramArray[] = $paramArray;
7678
}

src/Database/Procedures/Query.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private function executeStatement(&$stmt, array &$parameters = null) : ResultSet
126126
}
127127
}
128128
else {
129-
throw new VeloxException('PDO Error: SQLSTATE '.$stmt->errorCode().': '.$stmt->errorInfo()[2], $stmt->errorInfo()[1]);
129+
throw new VeloxException('PDO Error: SQLSTATE '.$stmt->errorCode().': '.$stmt->errorInfo()[2], $stmt->errorInfo()[1] ?? 0);
130130
}
131131
}
132132
break;
@@ -276,7 +276,7 @@ public function execute() : bool {
276276
}
277277
}
278278
else {
279-
$placeholders = array_fill(1,$this->getParamCount(),null);
279+
$placeholders = array_fill(0,$this->getParamCount(),null);
280280
}
281281
}
282282

@@ -292,7 +292,7 @@ public function execute() : bool {
292292
try {
293293
//PDOStatement::bindParam() is called once for each parameter.
294294
//Equivalent non-PDO parameter binding tends to be done once per statement using an array of parameters, so these calls happen outside the loop.
295-
$stmt->bindParam($key, $placeholders[$key]);
295+
$stmt->bindParam(is_int($key) ? $key+1 : $key, $placeholders[$key]);
296296
}
297297
catch (\PDOException $ex) {
298298
if (!($this->queryType == Query::QUERY_PROC && str_starts_with($key, ':op_'))) {

src/Database/Procedures/Transaction.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* The Transaction instance is itself callable, and invoking it as a function is a simple alias for calling {@see Transaction::executeAll()}.
3333
*
34-
* @version 1.0.0
34+
* @version 1.0.2
3535
* @since 1.0.0-alpha
3636
* @license https://www.mozilla.org/en-US/MPL/2.0/ Mozilla Public License 2.0
3737
*
@@ -72,7 +72,7 @@ public function __construct(?Connection &$conn = null) {
7272
* @ignore
7373
*/
7474
public function __invoke(bool $commit = false) : void {
75-
$this->executeAll();
75+
$this->executeAll($commit);
7676
}
7777

7878
/**

0 commit comments

Comments
 (0)