1

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,

?

2 Answers 2

2

Better you can try http://www.yiiframework.com/extension/yii-debug-toolbar/ which will show you the all sql queries traces.

Sign up to request clarification or add additional context in comments.

1 Comment

I need this code not for debug purposes. But thanks, I think toolbur will be useful too .)
1

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']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.