【tp5.1RC】model调用save出错,是解锁姿势不对?

浏览:1779 发布日期:2017/09/18
5.0.0 - 严重 - 已处理
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''

in Connection.php line 650
at Connection->query('SHOW COLUMNS FROM ``', [], false, true) in Mysql.php line 88
at Mysql->getFields('') in Connection.php line 356
at Connection->getTableInfo('', 'fields') in Connection.php line 398
at Connection->getTableFields('') in Model.php line 327
at Model->checkAllowFields([]) in Model.php line 378
at Model->updateData(['id' => 46]) in Model.php line 243
at Model->save(['update_time' => 1505677168], ['id' => 46]) in Drop.php line 27

追踪源码Model.php 320行

protected function checkAllowFields($append = [])
{
// 检测字段
if (empty($this->field) || true === $this->field) {
$query = $this->db(false);

###########################为什么返回空??????
$table = $query->getTable();


$this->field = $query->getConnection()->getTableFields($table);

$field = $this->field;
} else {
$field = array_merge($this->field, $append);

if ($this->autoWriteTimestamp) {
array_push($field, $this->createTime, $this->updateTime);
}
}
return $field;
}

在$model已定义了$table属性

$model->save($data, $where); // Error

save;insert都会出现上面的错误

$model->where($where)->update($data);//Ok

下面的写法执行正常
评论()
后面还有条评论,点击查看>>