From 2ffcc79b2849274d4c8a909f52ae8b98114be762 Mon Sep 17 00:00:00 2001 From: h2lsoft Date: Wed, 27 May 2020 18:40:12 +0200 Subject: [PATCH] fixed bind parameters for ID --- src/DBManager.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/DBManager.php b/src/DBManager.php index 270d878..77ae385 100644 --- a/src/DBManager.php +++ b/src/DBManager.php @@ -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); @@ -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;