trigger mirror
[m6w6/pq-gateway] / lib / pq / Query / WriterInterface.php
1 <?php
2
3 namespace pq\Query;
4
5 /**
6 * A query writer which supports easily constructing queries for \pq\Connection::execParams()
7 * @codeCoverageIgnore
8 */
9 interface WriterInterface
10 {
11 /**
12 * Returns the plain constructed query as string
13 * @return string
14 */
15 function __toString();
16
17 /**
18 * Returns a list of parameters as array
19 * @return array
20 */
21 function getParams();
22
23 /**
24 * Returns a list any types associated with the params
25 * @return array
26 */
27 function getTypes();
28
29 /**
30 * Reset the state of the query writer
31 * @return \pq\Query\WriterInterface
32 */
33 function reset();
34
35 /**
36 * Write plain SQL to the query
37 * @param mixed $arg variable list of arguments, arrays will be imploded to a comma separated list
38 * @return \pq\Query\WriterInterface
39 */
40 function write(/*...*/);
41
42 /**
43 * Remember the parameter with any associated type and return $N to be written to the query string
44 * @param mixed $param a literal parameter, a \pq\Gateway\Table\Cell or a \pq\Query\Expr
45 * @param int $type the oid of the type of the param
46 * @return \pq\Query\WriterInterface
47 */
48 function param($param, $type = null);
49
50 /**
51 * An array of AND/OR criteria
52 * @param array $criteria
53 */
54 function criteria(array $criteria);
55 }