gpt4 book ai didi

php - Yii CDbCommand 执行SQL语句失败 : SQLSTATE[42000]:

转载 作者:行者123 更新时间:2023-11-29 00:06:46 24 4
gpt4 key购买 nike

当我一段时间没有做任何事情时出现这个错误,我不确定这是否是 Session 问题。

错误信息是:

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=='1')' at line 1. The SQL statement executed was: SELECT * FROM games_developers_app t WHERE (status LIKE :ycp0) AND (developer_id==:ycp1)

代码是:

public function actionSortReject(){
$util = new Utility();
$util->detectMobileBrowser();
$util->checkWebSiteLanguageInCookies();
$this->layout = "masterLayout";

$count = '0';
$id = Yii::app()->user->getState('id');
$searchsort = "REJ";
$sort = new CDbCriteria();
$sort->addSearchCondition('status', $searchsort);
$sort->addCondition('developer_id='.$id);
$models = GamesDevelopersApp::model()->findAll($sort,array('developer_id'=>$id));
$this->render('/register/applist',array('models'=>$models,'count'=>$count));

}

看起来一切正常,如果我在代码中遗漏了什么请告诉我。谢谢 =)

最佳答案

问题是您如何调用 compare 的组合并向 findAll 添加了其他参数.

您的比较应该如下所示:

$sort->compare('developer_id', $id);

你的findAll应该是:

 $models = GamesDevelopersApp::model()->findAll($sort); 

您还可以按如下方式使用 addCondition:

$sort->addCondition('developer_id=:developer_id');
$sort->params[':developer_id'] = $id;

关于php - Yii CDbCommand 执行SQL语句失败 : SQLSTATE[42000]:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27164454/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com