function testSql_UpdateWhere() { $Sql_Update = new A_Sql_Update(); $this->assertEqual($Sql_Update->table('foobar')->set('foo', 'bar')->where('baz', 'faz')->render(), "UPDATE foobar SET foo = 'bar' WHERE (baz = 'faz')"); }
<?php include 'config.php'; $update = new A_Sql_Update(); $update->table('mytable')->set(array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'))->where('id', 1); echo "A_Sql_Update::render=" . $update->render() . '<br/>'; dump($update);
public function save($data = array()) { if ($data) { $this->_data = $data; } if (!$this->is_loaded) { $insert = new A_Sql_Insert(); $insert->table($this->table)->values($this->_data); $this->sql = $insert->render(); $this->db->query($this->sql); $try_update = !$this->db->isError(); } if (isset($this->_data[$this->key]) && ($this->is_loaded || $try_update)) { $update = new A_Sql_Update(); $update->table($this->table)->set($this->_data)->where($this->key, $this->_data[$this->key]); $this->sql = $update->render(); $this->db->query($this->sql); } return $this; }