0
我试图插入一些数据一起使用Yii框架与PDO对象表并收到以下错误Yii框架/ PDO得到错误CDbCommand未能执行SQL语句:SQLSTATE [42000]
我使用这个代码
$connection = CActiveRecord::getDbConnection();
$sql="INSERT INTO sms_logs (to, from, message,error_code,date_send) VALUES (:to,:from,:message,:error_code,:date_send)";
$command=$connection->createCommand($sql);
$command->bindParam(":to",$to,PDO::PARAM_STR);
$command->bindParam(":from",$from,PDO::PARAM_STR);
$command->bindParam(":message",$message,PDO::PARAM_STR);
$command->bindParam(":error_code",$code,PDO::PARAM_STR);
$command->bindParam(":date_send",date("Y-m-d H:i:s"),PDO::PARAM_STR);
$command->execute();
当我运行代码构建查询,然后我得到
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 'to, from, message,error_code,date_send) VALUES ('27724963345','27723663542','Hap' at line 1INSERT INTO sms_logs (to, from, message,error_code,date_send) VALUES (:to,:from,:message,:error_code,:date_send)
任何建议都欢迎!使用mySql作为分区
谢谢,我不能相信我忽视了保留字,问题解决了;-) – Roland 2010-02-24 07:12:34
很高兴将它排序。不要忘记CProfileLogRoute日志路径。它可以准确显示正在运行的查询,这可以帮助追踪问题。 – 2010-02-24 09:24:49