Skip to content

Commit

Permalink
fixed bind parameters for ID
Browse files Browse the repository at this point in the history
  • Loading branch information
h2lsoft committed May 27, 2020
1 parent 5a1a0ae commit 2ffcc79
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/DBManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,13 @@ protected function purgeQueryStack()
public function query($sql, $binds=[])
{
$this->purgeQueryStack();
if($sql != "SELECT FOUND_ROWS()")$this->last_query = $sql;
if($sql != "SELECT FOUND_ROWS()")
{
$this->last_query = $sql;
$this->last_query_params = $binds;
}

$this->error_interceptor(1);

if(!count($binds))
{
$this->query_stack[++$this->query_id] = $this->connection->query($sql);
Expand All @@ -180,7 +183,14 @@ public function query($sql, $binds=[])
$stmt = $this->prepare($sql);
foreach($binds as $bind => $value)
{
$stmt->bindParam($bind, $value);
if(preg_match("/ID$/", $bind))
{
$stmt->bindParam($bind, $value, PDO::PARAM_INT);
}
else
{
$stmt->bindParam($bind, $value);
}
}
$stmt->execute();
$this->query_stack[++$this->query_id] = $stmt;
Expand Down

0 comments on commit 2ffcc79

Please sign in to comment.