X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fpq-gateway;a=blobdiff_plain;f=lib%2Fpq%2FQuery%2FExecutor.php;fp=lib%2Fpq%2FQuery%2FExecutor.php;h=a01580a030231116fc1465526e29e4218bb7f522;hp=0000000000000000000000000000000000000000;hb=dc87da9c4ec52918e34f2e43eac3014f0f99a8bc;hpb=519b07c17830f76e97b269a4b2a4936b02a4eae7 diff --git a/lib/pq/Query/Executor.php b/lib/pq/Query/Executor.php new file mode 100644 index 0000000..a01580a --- /dev/null +++ b/lib/pq/Query/Executor.php @@ -0,0 +1,50 @@ +conn = $conn; + } + + /** + * @inheritdoc + * @return \pq\Connection + */ + function getConnection() { + return $this->conn; + } + + /** + * @inheritdoc + * @param \pq\Connection $conn + * @return \pq\Query\Executor + */ + function setConnection(\pq\Connection $conn) { + $this->conn = $conn; + return $this; + } + + /** + * Execute the query synchronously through \pq\Connection::execParams() + * @param \pq\Query\WriterInterface $query + * @param callable $callback + * @return mixed + */ + function execute(WriterInterface $query, callable $callback) { + return $callback($this->getConnection()->execParams($query, $query->getParams(), $query->getTypes())); + } +}