Yii2 querybuilder 正确语法 table 名称与原始 sql
Yii2 querybuilder correct syntax for table names with raw sql
谁能告诉我我在这个声明中做错了什么
$connection = Yii::$app->db;
$result=$connection->createCommand("SHOW TABLE STATUS LIKE
{{%promo_deliveries}}")->execute();
我遇到了这个错误
Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax
error or access violation: 1064 You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for
the right syntax to use near 'sms_promo_deliveries
' at line 1 The
SQL being executed was: `SHOW TABLE STATUS LIKE sms_promo_deliveries'
in
F:\xampp\htdocs\Nxb\sms_protected\vendor\yiisoft\yii2\db\Schema.php:631
Error Info: Array (
[0] => 42000
[1] => 1064
[2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
near 'sms_promo_deliveries
' at line 1 )
这与使用查询生成器时的 table 命名约定无关,实际上这是指定的语法错误,必须在 table 名称周围添加引号,因为我正在使用LIKE
关键字匹配 table 名称。
$result=$connection->createCommand("SHOW TABLE STATUS LIKE
'{{%promo_deliveries}}'")->execute();
谁能告诉我我在这个声明中做错了什么
$connection = Yii::$app->db;
$result=$connection->createCommand("SHOW TABLE STATUS LIKE
{{%promo_deliveries}}")->execute();
我遇到了这个错误
Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
sms_promo_deliveries
' at line 1 The SQL being executed was: `SHOW TABLE STATUS LIKE sms_promo_deliveries'in F:\xampp\htdocs\Nxb\sms_protected\vendor\yiisoft\yii2\db\Schema.php:631
Error Info: Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
sms_promo_deliveries
' at line 1 )
这与使用查询生成器时的 table 命名约定无关,实际上这是指定的语法错误,必须在 table 名称周围添加引号,因为我正在使用LIKE
关键字匹配 table 名称。
$result=$connection->createCommand("SHOW TABLE STATUS LIKE
'{{%promo_deliveries}}'")->execute();