import poc
[m6w6/pq-gateway] / lib / tmp.php
1 <?php
2
3 require "./pq/Query/Expr.php";
4 require "./pq/Query/Writer.php";
5 require "./pq/Gateway/Table.php";
6 require "./pq/Gateway/Rowset.php";
7 require "./pq/Gateway/Row.php";
8 require "./pq/Gateway/Cell.php";
9
10 class FooModel extends \pq\Gateway\Table {
11 function __construct(\pq\Connection $c) {
12 parent::__construct($c, "foo", "FooCollection");
13 }
14 }
15
16 class Foo extends \pq\Gateway\Row {
17
18 }
19
20 class FooCollection extends \pq\Gateway\Rowset {
21 function __construct(\pq\Gateway\Table $table, \pq\Result $result) {
22 parent::__construct($table, $result, "Foo");
23 }
24 }
25
26 $conn = new \pq\Connection;
27 $types = new \pq\Types($conn);
28 $table = new FooModel($conn);
29 print_r( $table->find(array("dt" => new \pq\Query\Expr("between %s and %s", $conn->quote("2013-03-01"), $conn->quote("2013-03-04")))) );
30 echo PHP_EOL;
31 print_r( $table->find(array("id>" => 1, "OR" => array(array("id=" => 1), array("id="=>2)))));
32 echo PHP_EOL;
33 print_r( $table->find(array("OR" => array("id>" => 1, "OR" => array(array("id=" => 1), array("id="=>2))))));
34 echo PHP_EOL;
35 print_r( $table->create(array("data" => "blabla")) );
36 echo PHP_EOL;
37 print_r( $table->create(array("data" => new \pq\Query\Expr("DEFAULT"))) );
38 echo PHP_EOL;
39 print_r( $table->update(array("id=" => 4), array("data" => "die 4")) );
40 echo PHP_EOL;
41 print_r( $table->delete(array(new \pq\Query\Expr("data is null"))) );
42 echo PHP_EOL;