使用表前缀时报错 [ 未指定版本 ]
Yii版本:1.1.17-dev
$connection=new CDbConnection('mysql:host=localhost;dbname=test');
$sql='select * from {{user}}';
$res=$connection->createCommand($sql)->queryAll();
配置里面也加了tablePrefix
'connectionString' => 'mysql:host=localhost;dbname=test',
'emulatePrepare' => true,
'username' => 'root',
'password' => '123456',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
运行后提示SQL语法错误:
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 '{user}}' at line 1. The SQL statement executed was: select * from {{user}}
共 3 个回答
-
表前面还要加百分号
共 3 条回复qf19910623 回复于 2015-07-22 14:35 回复真坑,文档里面没有百分号
qf19910623 回复于 2015-07-22 14:44 回复不行,还是报错
@qf19910623 那你就不要这么写在你表前面加上表前缀就可以了,把括号都去掉
lilongsy 觉得很赞 -
-
qf19910623
注册时间:2015-07-20
最后登录:2020-01-17
在线时长:2小时2分
最后登录:2020-01-17
在线时长:2小时2分
- 粉丝0
- 金钱10
- 威望0
- 积分30