Implemented changes requested by Wettennet.
PDOStatementWrapper now directly binds parameters. This allows for values such as 'NULL' to be properly utilized.
This commit is contained in:
parent
72b404ecc9
commit
6c53eb8cd4
|
@ -101,7 +101,10 @@ class PDOStatementWrapper
|
|||
{
|
||||
// Run the query and benchmark the time
|
||||
$benchmarkStart = microtime(true);
|
||||
$result = $this->statement->execute($input_parameters);
|
||||
if (empty($input_parameters))
|
||||
$result = $this->statement->execute();
|
||||
else
|
||||
$result = $this->statement->execute($input_parameters);
|
||||
$benchmarkEnd = microtime(true) - $benchmarkStart;
|
||||
$errInfo = $this->error();
|
||||
call_user_func_array($this->logQueryCallable, [$this->statement->queryString, $this->statement->rowCount(), $benchmarkEnd, $errInfo]);
|
||||
|
@ -128,6 +131,16 @@ class PDOStatementWrapper
|
|||
return $this->statement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the query string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQuery(): string
|
||||
{
|
||||
return $this->statement->queryString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an error message for the last failure in PDO
|
||||
*
|
||||
|
|
|
@ -186,7 +186,15 @@ class PDOTableModel implements iDatabaseTableModel
|
|||
$this->lastStatement = $this->dbEngine->prepare($sql);
|
||||
|
||||
// And execute the query
|
||||
$this->lastStatement->execute($filter);
|
||||
foreach ($filter as $key => $val)
|
||||
{
|
||||
if (is_null($val))
|
||||
$this->lastStatement->bindValue(':' . $key, $val, PDO::PARAM_NULL);
|
||||
else
|
||||
$this->lastStatement->bindValue(':' . $key, $val);
|
||||
}
|
||||
|
||||
$this->lastStatement->execute();
|
||||
|
||||
// Fetch PDO Iterable
|
||||
return new TableModelResult($this->lastStatement->getStatement());
|
||||
|
|
Loading…
Reference in New Issue