Reputation: 23748
Can anyone tell me what is it that I am doing wrong in this statement
$connection = Yii::$app->db;
$result=$connection->createCommand("SHOW TABLE STATUS LIKE
{{%promo_deliveries}}")->execute();
I am getting this error
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 )
Upvotes: 1
Views: 298
Reputation: 23748
This had nothing to do with the table naming convention when using query builder in fact it was a syntax error as specified, had to add quotes around the table name as i was using the LIKE
keyword to match the table name.
$result=$connection->createCommand("SHOW TABLE STATUS LIKE
'{{%promo_deliveries}}'")->execute();
Upvotes: 1