Пример #1
0
 public function setDefault()
 {
     $this->_db->update(':theme', ['is_default' => 0], ['is_default' => 1]);
     $this->_db->update(':theme_style', ['is_default' => 0], ['is_default' => 1]);
     $this->_db->update(':theme', ['is_default' => 1], ['theme_id' => $this->theme_id]);
     $this->_db->update(':theme_style', ['is_default' => 1], ['style_id' => $this->flavor_id]);
     return true;
 }
Пример #2
0
 /**
  * 更新记录
  *
  * @param array $data 更新数据
  * @param array $filter 更新条件
  * @return int
  */
 public function update($data, array $filter)
 {
     $sql = "UPDATE {$this->tableName} SET ";
     $split = '';
     foreach ($data as $key => $val) {
         $sql .= "{$split}`{$key}` = :{$key}";
         $split = ', ';
     }
     if (!empty($filter)) {
         $sql .= " WHERE " . $this->parseFilter($filter);
     }
     return $this->db->update($sql, $data);
 }