- 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) {
switch(strtolower(gettype($value))) {
case "boolean":
$statement->bindValue($key, $value, Pdo::PARAM_BOOL);
$type = Pdo::PARAM_BOOL;
break;
case "integer":
$statement->bindValue($key, $value, Pdo::PARAM_INT);
$type = Pdo::PARAM_INT;
break;
case "null":
$statement->bindValue($key, $value, Pdo::PARAM_NULL);
$type = Pdo::PARAM_NULL;
break;
case "string":
default:
$statement->bindValue($key, (string) $value, Pdo::PARAM_STR);
$type = Pdo::PARAM_STR;
}
$statement->bindValue($key, (string) $value, $type);
}
$this->executionStatus = $statement->execute();

View File

@ -24,8 +24,9 @@ class Values extends Fragment {
if ($this->fieldCount === null) {
$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;
}

View File

@ -84,7 +84,7 @@ abstract class Ulmus
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();
return $return;