ThinkPHP 模型进行更新记录报错:miss update condition

本人使用的是ThinkPHP 5.0.24,报错信息:

object(think\Exception)[17]
  protected 'data' =>
    array (size=0)
      empty
  protected 'message' => string 'miss update condition'

一、报错程序代码

$model = new ModelTest;

$updateCondition = array(
    'id' => intval($param['id'])
);

$updateCondition['name'] = $param['name'];

try {
    $model->update($updateCondition);
} catch (Exception $e) {
    var_dump($e);
}

二、更改后的代码

$model = new ModelTest;

$updateCondition = array();

$updateCondition['name'] = $param['name'];

try {
    $where = array('id' => intval($param['id']));
    $model->update($updateCondition, $where);
} catch (Exception $e) {
    var_dump($e);
}

更改后,不会报错

你可能感兴趣的:(ThinkPHP)