/** * 更新$id对应的记录 * @param $id * @param $data * @return int */ public function update($id = null, $data = array()) { if (is_array($data) && !empty($data)) { $this->fill($data); } if ($id !== null) { $this->_id = $id; } $pk = $this->_table->getPrimaryKey(); unset($this->_row[$pk]); $cond = $this->_table->getCondition(); $cond->add($pk, $this->_id); return $this->_table->update($this->_row); }