From af85dc85312caac90f9777f1627e58ce20ac0619 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 7 Feb 2017 14:01:58 +0100 Subject: [PATCH] Implement parameter binds --- DataStorage/Database/Query/Builder.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index ce07ca2d7..6da4de9e1 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -1038,8 +1038,34 @@ class Builder extends BuilderAbstract public function execute() { $sth = $this->connection->con->prepare($this->toSql()); + + foreach($this->binds as $key => $bind) { + $type = $this->getBindParamType($bind); + + $sth->bindParam($key, $bind, $type); + } + $sth->execute(); return $sth; } + + /** + * Get bind parameter type. + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function getBindParamType($value) + { + if(is_int($value)) { + return PDO::PARAM_INT; + } elseif(is_string($value)) { + return PDO::PARAM_STR; + } + + throw new \Exception(); + } }