--- /dev/null
+# class pq\Query\AsyncExecutor extends pq\Query\Executor
+
+An asynchronous query executor implementation.
+See pq\Query\Executor for inherited methods and properties.
+
+> ***NOTE:***
+ This asynchronous executor implementation depends on [React/Promise](https://github.com/reactphp/promise).
--- /dev/null
+# Promise pq\Query\AsyncExecutor::execute(pq\Query\WriterInterface $query, callable $callback)
+
+Execute the query asynchronously and let the callback process the result on resolve.
+
+> ***NOTE:***
+ This asynchronous executor implementation depends on [React/Promise](https://github.com/reactphp/promise).
+
+## Params:
+
+* pq\Query\Writer $query
+ The query to execute.
+* callable $callback
+ The result processing callback as function(pq\Result $result)
+
+## Returns:
+
+* mixed, the return value of the callback.
+
--- /dev/null
+# class pq\Query\Executor implements pq\Query\ExecutorInterface
+
+A synchronous query executor implementation.
+
+## Properties:
+
+* protected pq\Connection $conn
+ The PostgreSQL connection.
+* protected SplObjectStorage $observers
+ Attached observers.
+* protected pq\Query\WriterInterface
+ The query being executed.
+* protected pq\Result $result
+ The query result.
+
--- /dev/null
+# void pq\Query\Executor::__construct(pq\Connection $conn)
+
+Create a new query executor.
+
+## Params:
+
+* pq\Connection $conn
+ The PostgreSQL connection to use.
+
--- /dev/null
+# void pq\Query\Executor::attach(SplObserver $observer)
+
+Implements SplSubject.
+Attach a new observer.
+
+## Params:
+
+* SplObserver $observer
+
--- /dev/null
+# void pq\Query\Executor::detach(SplObserver $observer)
+
+Implements SplSubject.
+Detach an observer.
+
+## Params:
+
+* SplObserver $observer
+ An observer already attached.
--- /dev/null
+# mixed pq\Query\Executor pq\Query\Executor::execute(\pq\Query\Writer $query, callable $callback);
+
+Execute the query and process the result with the callback.
+
+## Params:
+
+* pq\Query\Writer $query
+ The query to execute.
+* callable $callback
+ The result processing callback as function(pq\Result $result)
+
+## Returns:
+
+* mixed, the return value of the callback.
+
--- /dev/null
+# pq\Connection pq\Query\Executor::getConnection()
+
+Retrieve the coonection used by the executor.
+
+## Params:
+
+None.
+
+## Returns:
+
+* pq\Connection, the currently used connection.
--- /dev/null
+# pq\Query\Writer pq\Query\Executor::getQuery()
+
+Retrieve the current query.
+
+## Params:
+
+None.
+
+## Returns:
+
+* pq\Query\Writer, the current query to execute.
--- /dev/null
+# pq\Result pq\Query\Executor::getResult()
+
+Retrieve the result of the current query.
+
+## Params:
+
+None.
+
+## Returns:
+
+* pq\Result, the result of the current query.
--- /dev/null
+# void pq\Query\Executor::notify()
+
+Implements SplSubject.
+Update all observers.
+
+## Params:
+
+None.
--- /dev/null
+# pq\Query\Executor pq\Query\Executor::setConnection(pq\Connection $conn)
+
+Set the connection the executor should use.
+
+## Params:
+
+* pq\Connection $conn
+ The connection to use.
+
+## Return:
+
+* pq\Query\Executor, self.
--- /dev/null
+# interface pq\Query\ExecutorInterface extends SplSubject
+
+API to execute queries assembled by pq\Query\WriterInterface.
+
--- /dev/null
+# mixed pq\Query\ExecutorInterface pq\Query\ExecutorInterface::execute(\pq\Query\WriterInterface $query, callable $callback);
+
+Execute the query and process the result with the callback.
+
+> ***NOTE:***
+ This method should notify the observers twice.
+ Once before the query gets executed and can be retrieved by pq\Query\ExecutorInterface::getQuery().
+ And once after executing the query and the result can be retrieved by pq\Query\ExecutorInterface::getResult().
+
+## Params:
+
+* pq\Query\WriterInterface $query
+ The query to execute.
+* callable $callback
+ The result processing callback as function(pq\Result $result)
+
+## Returns:
+
+* mixed, the return value of the callback.
+
--- /dev/null
+# pq\Connection pq\Query\ExecutorInterface::getConnection()
+
+Retrieve the coonection used by the executor.
+
+## Params:
+
+None.
+
+## Returns:
+
+* pq\Connection, the currently used connection.
--- /dev/null
+# pq\Query\WriterInterface pq\Query\ExecutorInterface::getQuery()
+
+Retrieve the current query.
+
+## Params:
+
+None.
+
+## Returns:
+
+* pq\Query\WriterInterface, the current query to execute.
--- /dev/null
+# pq\Result pq\Query\ExecutorInterface::getResult()
+
+Retrieve the result of the current query.
+
+## Params:
+
+None.
+
+## Returns:
+
+* pq\Result, the result of the current query.
--- /dev/null
+# pq\Query\ExecutorInterface pq\Query\ExecutorInterface::setConnection(pq\Connection $conn)
+
+Set the connection the executor should use.
+
+## Params:
+
+* pq\Connection $conn
+ The connection to use.
+
+## Return:
+
+* pq\Query\ExecutorInterface, self.
--- /dev/null
+# class pq\Query\Expr
+
+A query expression.
+
+## Properties:
+
+* protected string $expression
+ The expression.
+* protected pq\Query\Expr $next
+ The next expression in a linked list.
--- /dev/null
+# void pq\Query\Expr::__construct(string $e[, string ...$args])
+
+Create a new expression.
+If the number of arguments is greater than 1, then all arguments are stringified by sprintf.
+
+## Params:
+
+* string $e
+ The expression (possibly a sprintf format string).
+* string ...$args
+ A variable list of sprintf substitution parameters.
+
--- /dev/null
+# string pq\Query\Expr::__toString()
+
+Retrieve the string representation.
+All of the expressions within the linked list are concatenated.
+
+## Params:
+
+None.
+
+## Returns:
+
+* string, the expression and all next expressions concatenated.
--- /dev/null
+# pq\Query\Expr pq\Query\Expr::add(pq\Query\Expr $next)
+
+Add an expression at the end of the linked list.
+
+## Params:
+
+* pq\Query\Expr $next
+ The expression to add.
+
+## Returns:
+
+* pq\Query\Expr, self.
+
+## Throws:
+
+* UnexpectedValueException, if the receiving expression is NULL.
--- /dev/null
+# bool pq\Query\Expr::isNull()
+
+Whether the expression is the literal NULL.
+
+## Params:
+
+None.
+
+## Returns:
+
+* bool, whether the expression case insensitively equals NULL.
--- /dev/null
+# class pq\Query\Expressible implements pq\Query\ExpressibleInterface
+
+An implementation to express column data changes.
+See pq\Query\Expressible::mod() for an example.
+
+## Properties:
+
+* protected string $name
+ The name.
+* protected mixed $data
+ The data.
--- /dev/null
+# void pq\Query\Expressible::__construct(string $name, mixed $data)
+
+Create a new column data change expression.
+
+## Params:
+
+* string $name
+ The name (of the column).
+* mixed $data
+ The data (of the column).
--- /dev/null
+# string pq\Query\Expressible::__toString()
+
+Retrieve the contained value as string.
+
+## Params:
+
+None.
+
+## Returns:
+
+* string, the contained value.
--- /dev/null
+# mixed pq\Query\Expressible::get()
+
+Retrieve the contained value.
+
+## Params:
+
+None.
+
+## Returns:
+
+* mixed, the contained data/expression.
--- /dev/null
+# bool pq\Query\Expressible::isExpr()
+
+Check whether the implementor already contains a expression, i.e. pq\Query\Expr.
+
+## Params:
+
+None.
+
+## Returns:
+
+* bool, whether we actually contain an expression.
+
--- /dev/null
+# pq\Query\Expressible pq\Query\Expressible::mod(mixed $data[, string $op = NULL])
+
+Modify the contained data, turning it into an expression, i.e. pq\Query\Expr.
+
+## Params:
+
+* mixed $data
+ Modifying data.
+* Optional string $op = NULL
+ The intended operator (defaults to "+" for numeric values and "||" for strings).
+
+## Returns:
+
+* pq\Query\Expressible, self.
+
+
+## Example:
+
+ <?php
+
+ $column = new pq\Query\Expressible("example", 5);
+ var_dump($column->isExpr(), (string) $column, $column->get());
+
+ echo "\n";
+
+ $column->mod(1); // append "+ 1"
+ var_dump($column->isExpr(), (string) $column, $column->get());
+
+ echo "\n";
+
+ $column->set("'Hello'");
+ var_dump($column->isExpr(), (string) $column, $column->get());
+
+ echo "\n";
+
+ $column->mod("' World!'");
+ var_dump($column->isExpr(), (string) $column, $column->get());
+
+ ?>
+
+Yields:
+
+ bool(false)
+ string(1) "5"
+ int(5)
+
+ bool(true)
+ string(11) "example + 1"
+ object(pq\Query\Expr)#3 (2) {
+ ["expression":protected]=>
+ string(7) "example"
+ ["next":protected]=>
+ object(pq\Query\Expr)#4 (2) {
+ ["expression":protected]=>
+ string(3) "+ 1"
+ ["next":protected]=>
+ NULL
+ }
+ }
+
+ bool(false)
+ string(7) "'Hello'"
+ string(7) "'Hello'"
+
+ bool(true)
+ string(20) "example || ' World!'"
+ object(pq\Query\Expr)#3 (2) {
+ ["expression":protected]=>
+ string(7) "example"
+ ["next":protected]=>
+ object(pq\Query\Expr)#4 (2) {
+ ["expression":protected]=>
+ string(12) "|| ' World!'"
+ ["next":protected]=>
+ NULL
+ }
+ }
--- /dev/null
+# pq\Query\Expressible pq\Query\Expressible::set(mixed $data)
+
+Set the contained data.
+
+## Params:
+
+* mixed $data
+ The data.
+
+## Returns:
+
+* pq\Query\Expressible, self.
--- /dev/null
+# interface ExpressibleInterface
+
+API to express column data changes.
--- /dev/null
+# string pq\Query\ExpressibleInterface::__toString()
+
+Retrieve the contained value as string.
+
+## Params:
+
+None.
+
+## Returns:
+
+* string, the contained value.
--- /dev/null
+# mixed pq\Query\ExpressibleInterface::get()
+
+Retrieve the contained value.
+
+## Params:
+
+None.
+
+## Returns:
+
+* mixed, the contained data/expression.
--- /dev/null
+# bool pq\Query\ExpressibleInterface::isExpr()
+
+Check whether the implementor already contains a expression, i.e. pq\Query\Expr.
+
+## Params:
+
+None.
+
+## Returns:
+
+* bool, whether we actually contain an expression.
+
--- /dev/null
+# pq\Query\ExpressibleInterface pq\Query\ExpressibleInterface::mod(mixed $data[, string $op = NULL])
+
+Modify the contained data, turning it into an expression, i.e. pq\Query\Expr.
+
+## Params:
+
+* mixed $data
+ Modifying data.
+* Optional string $op = NULL
+ The intended operator (defaults to "+" for numeric values and "||" for strings).
+
+## Returns:
+
+* pq\Query\ExpressibleInterface, self.
--- /dev/null
+# pq\Query\ExpressibleInterface pq\Query\ExpressibleInterface::set(mixed $data)
+
+Set the contained data.
+
+## Params:
+
+* mixed $data
+ The data.
+
+## Returns:
+
+* pq\Query\ExpressibleInterface, self.
--- /dev/null
+# void pq\Query\Writer::__construct([string $query = ""[, array $params = array()[, array $types = array()]]])
+
+Create a new query writer.
+
+## Params:
+
+* Optional string $query = ""
+ The initial query string.
+* Optional array $params = array()
+ The initial query parameters.
+* Optional array $types = array()
+ The initial query parameters' types.
Write nested AND/OR criteria to the query string.
+The criteria can either be a simple accociative array, where the keys build the left hand operand plus the operator and the values make up the right hand operand and will be passed to pq\Query\Writer::param(). All concatenated together by AND clauses.
+
+Using multiple arrays, the above logic will be applied to each array and then concatenated by OR clauses.
+
## Params:
* array $criteria
## Returns:
-* string, '$N', to be used with pq\Query\Writer::write(), where N is tne number of this parameter.
+* string, '$N', to be used with pq\Query\Writer::write(), where N is the number of this parameter.
## Example:
--- /dev/null
+# protected string pq\Query\Writer::reduce(string $q, mixed $v)
+
+An array_reduce() helper for pq\Query\Writer::write().
+
+## Params:
+
+* string $q
+ Query string.
+* mixed $v
+ Query parts to append to $q, joined by commas if of type array.
+
+## Returns:
+
+* string, the concatenated arguments.
+
+
## Returns:
* pq\Query\WriterInterface, self.
-
-## Example:
-
- <?php
-
- use pq\Query;
-
- $q = new Query\Writer;
- $q->write("select * from account where")
- ->criteria([
- ["id >" => 1, "id <" => 5],
- ["name =" => "mike"]
- ]);
-
- var_dump((string) $q, $q->getParams());
-
- ?>
-
-Yields:
-
- string(84) "select * from account where ( ( ( id > $1 ) AND ( id < $2 ) ) OR ( ( name = $3 ) ) )"
- array(3) {
- [0]=>
- int(1)
- [1]=>
- int(5)
- [2]=>
- string(4) "mike"
- }
## Returns:
-* string, '$N', to be used with pq\Query\WriterInterface::write(), where N is tne number of this parameter.
-
-## Example:
-
- <?php
-
- use pq\Query;
-
- $writer = new Query\Writer;
- $writer->write("SELECT", $writer->param(1));
-
- var_dump((string) $writer, $writer->getParams());
-
- ?>
-
-Yields:
-
- string(9) "SELECT $1"
- array(1) {
- [0]=>
- int(1)
- }
+* string, '$N', to be used with pq\Query\WriterInterface::write(), where N is the number of this parameter.