Reputation: 2567
I want to display sql code of the executed statement like SHOW CREATE TABLE my_table
, but it return 1
meaning the exution was successful, so how I can see the code like
CREATE TABLE `my_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` varchar(255) NOT NULL,
?
Upvotes: 1
Views: 140
Reputation: 3024
Better you can try http://www.yiiframework.com/extension/yii-debug-toolbar/ which will show you the all sql queries traces.
Upvotes: 2
Reputation: 5094
Try this
$result=Yii::app()->db->createCommand('SHOW CREATE TABLE my_table')->queryRow();
This will give you an array containing table name
and the sql query for creating the table
. Eg:-
array
(
'Table'=>'my_table',
'Create Table'=>'Query For Creating Table'
)
SO you can get the desired result using
$result['Create Table']
Upvotes: 1