- Fixed a bug within INSERT query

This commit is contained in:
Dave M. 2023-11-17 23:34:55 -05:00
parent 3a80fee9c3
commit 62792e8325
3 changed files with 10 additions and 7 deletions

View File

@ -85,21 +85,23 @@ class PdoObject extends PDO {
foreach($parameters as $key => $value) { foreach($parameters as $key => $value) {
switch(strtolower(gettype($value))) { switch(strtolower(gettype($value))) {
case "boolean": case "boolean":
$statement->bindValue($key, $value, Pdo::PARAM_BOOL); $type = Pdo::PARAM_BOOL;
break; break;
case "integer": case "integer":
$statement->bindValue($key, $value, Pdo::PARAM_INT); $type = Pdo::PARAM_INT;
break; break;
case "null": case "null":
$statement->bindValue($key, $value, Pdo::PARAM_NULL); $type = Pdo::PARAM_NULL;
break; break;
case "string": case "string":
default: default:
$statement->bindValue($key, (string) $value, Pdo::PARAM_STR); $type = Pdo::PARAM_STR;
} }
$statement->bindValue($key, (string) $value, $type);
} }
$this->executionStatus = $statement->execute(); $this->executionStatus = $statement->execute();

View File

@ -25,7 +25,8 @@ class Values extends Fragment {
$this->fieldCount = count($row); $this->fieldCount = count($row);
} }
$this->rows[] = array_values($row); # index starts at '1' for Pdo params
$this->rows[] = array_combine(range(1, count($row)), array_values($row));
return $this; return $this;
} }

View File

@ -84,7 +84,7 @@ abstract class Ulmus
public static function runInsertQuery(Query\QueryBuilderInterface $queryBuilder, ? ConnectionAdapter $adapter = null) public static function runInsertQuery(Query\QueryBuilderInterface $queryBuilder, ? ConnectionAdapter $adapter = null)
{ {
$return = static::connector($adapter)->runInsertQuery($queryBuilder->render(), array_merge($queryBuilder->values ?? [], $queryBuilder->parameters ?? [])); $return = static::connector($adapter)->runInsertQuery($queryBuilder->render(),$queryBuilder->values ?? []);
$queryBuilder->reset(); $queryBuilder->reset();
return $return; return $return;