【问题标题】:Column not found: 1054 Unknown column in cake php未找到列:1054 蛋糕 php 中的未知列
【发布时间】:2015-02-16 17:00:14
【问题描述】:

我在更新查询期间遇到问题。

型号代码

public function resetpassword($key,$password)
{
$aresetpassword = $this->updateAll(array('Register.password'=>$password), array('Register.key'=>$key)); 
return($aresetpassword);
}

查看页面错误

错误:SQLSTATE[42S22]:找不到列:1054 未知列 '字段列表'中的'8815061c1a6c63398b9a2dfb1f44aae89dd59bfd'

SQL 查询:

UPDATE `milgyonu_mber`.`registers` AS `Register` 
SET `Register`.`password` = 8815061c1a6c63398b9a2dfb1f44aae89dd59bfd 
WHERE `Register`.`key` = '656abe3991a51c62e860b8d1401e4f49'

事件密码字段存在于我的表中。

【问题讨论】:

    标签: cakephp


    【解决方案1】:

    正如manual 中所述,在使用 Model::updateAll() 时,您需要在 $fields 参数中手动引用文字。所以使用array('Register.password'=> '"' . $password . '"')

    【讨论】:

    • 或者更好地使用DboSource::value() 来消除这最终成为可能的SQL 注入漏洞的可能性。 'Register.password'=> $this->getDataSource()->value($password)
    猜你喜欢
    • 2015-02-22
    • 1970-01-01
    • 2016-04-09
    • 1970-01-01
    • 2020-05-13
    • 2019-01-13
    • 2012-08-18
    • 1970-01-01
    相关资源
    最近更新 更多