/** * 更新记录 * * 如果 $row 参数中包含所有主键字段的值,并且没有指定 $where 参数,则假定更新主键字段值相同的记录。 * * 如果 $row 是一个 QDB_Expr 表达式,则根据表达式内容更新数据库。 * * @param array|QDB_Expr $row 要更新的记录值 * @param mixed $where 更新条件 */ function update($row, $where = null) { if (!$this->_inited) { $this->init(); } if (is_null($where)) { if (is_array($row)) { $where = array(); foreach ($this->_pk as $pk) { if (!isset($row[$pk]) || strlen($row[$pk]) == 0) { $where = array(); break; } $where[$pk] = $row[$pk]; } $where = array($where); } else { $where = null; } } elseif ($where) { $where = func_get_args(); array_shift($where); } $this->_conn->update($this->getFullTableName(), $row, $where, self::$_fields[$this->_cache_id]); }