nowiko
nowiko

Reputation: 2567

Display sql of executed statement Yii

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

Answers (2)

Suriyan Suresh
Suriyan Suresh

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

Let me see
Let me see

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

Related Questions