Skip to content

Commit

Permalink
Merge pull request #14 from martok/pdo-params
Browse files Browse the repository at this point in the history
Improve parameter handling for PDO connections
  • Loading branch information
nicksagona authored Jan 2, 2024
2 parents a10e13e + b2dab95 commit 9897374
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Sql/AbstractSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,15 @@ public function getParameter(mixed $value, ?string $column = null): string

$this->incrementParameterCount();

if (($detectedDbType !== null) && ($this->dbType != $detectedDbType)) {
switch ($this->dbType) {
// If the parameter is given in a different format than what the db expects, translate it
$realDbType = $this->dbType;
if ($this->placeholder == ':') {
// Either native SQLITE or PDO, in which case also use :param syntax
$realDbType = self::SQLITE;
}

if (($detectedDbType !== null) && ($realDbType != $detectedDbType)) {
switch ($realDbType) {
case self::MYSQL:
case self::SQLSRV:
$parameter = '?';
Expand Down

0 comments on commit 9897374

Please sign in to comment.