*/
function mod($data, $op = null) {
if (!($this->data instanceof Expr)) {
+ $this->data = new Expr($this->name);
+ /*
if (!isset($this->data)) {
$this->data = new Expr($this->name);
} elseif (is_numeric($this->data)) {
} else {
$this->data = new Expr("%s", $this->row->getTable()->getConnection()->quote($this->data));
}
+ */
}
if ($data instanceof Expr) {
return $where;
}
+ protected function changes() {
+ $changes = array();
+ foreach ($this->mods as $name => $cell) {
+ $changes[$name] = $cell->get();
+ }
+ return $changes;
+ }
+
/**
* Get a cell
* @param string $p
* @return \pq\Gateway\Row
*/
function create() {
- $this->data = $this->table->create($this->mods)->current()->data;
+ $this->data = $this->table->create($this->changes())->current()->data;
$this->mods = array();
return $this;
}
* @return \pq\Gateway\Row
*/
function update() {
- $this->data = $this->table->update($this->criteria(), $this->mods)->current()->data;
+ $this->data = $this->table->update($this->criteria(), $this->changes())->current()->data;
$this->mods = array();
return $this;
}
function param($param, $type = null) {
if ($param instanceof Expr) {
return (string) $param;
+ } else {
+ var_dump($param);
}
$this->params[] = $param;
$conn = new \pq\Connection;
$types = new \pq\Types($conn);
$table = new FooModel($conn);
-print_r( $table->find(array("dt" => new \pq\Query\Expr("between %s and %s", $conn->quote("2013-03-01"), $conn->quote("2013-03-04")))) );
-echo PHP_EOL;
-print_r( $table->find(array("id>" => 1, "OR" => array(array("id=" => 1), array("id="=>2)))));
-echo PHP_EOL;
-print_r( $table->find(array("OR" => array("id>" => 1, "OR" => array(array("id=" => 1), array("id="=>2))))));
-echo PHP_EOL;
-print_r( $table->create(array("data" => "blabla")) );
-echo PHP_EOL;
-print_r( $table->create(array("data" => new \pq\Query\Expr("DEFAULT"))) );
-echo PHP_EOL;
-print_r( $table->update(array("id=" => 4), array("data" => "die 4")) );
-echo PHP_EOL;
-print_r( $table->delete(array(new \pq\Query\Expr("data is null"))) );
+$rowset = $table->find(array(array("id>" => 1), array("id IS" => new pq\Query\Expr("NULL"))));
+$current = $rowset->current();
+$current->dt->mod(new pq\Query\Expr("- interval '3 day'"));
+$current->update();
+var_dump($current);
echo PHP_EOL;
\ No newline at end of file