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;