示例#1
0
<?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);
示例#2
0
 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;
 }