public function update($data, $where) { if (!is_array($data)) { throw new LibraryException('参数错误:$data'); } if (!is_array($where) || empty($where)) { throw new LibraryException('参数错误:$where'); } // 如果$data为空,说明不需要更新,affected_rows为0 if (empty($data)) { return 0; } // 自动添加update_time,前提是字段在表中存在并且未传 if (array_key_exists('update_time', $this->fieldTypes) && !array_key_exists('update_time', $data)) { $data['update_time'] = time(); } // 更新 $sql = $this->sqlBuilder->createUpdateSql($data, $where); $affects = $this->masterHandle->update($sql); // 清除该表所有静态缓存 if (!empty($affects)) { unset(self::$rowCache[$this->dbName][$this->tableName]); } return $affects; }