Yii Framework Forum: Ability to print/get final SQL queries - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ability to print/get final SQL queries

#1 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 19 June 2012 - 04:41 PM

Something that people ask for/about now and then in the #yii channel over at freenode, is the ability to print/get the SQL query that would be generated from a given CDbCriteria instance, data provider and similar structures in yii.

Is this something that makes sense? If it does perhaps it's something that should be considered. I realize a CDbCriteria might not contain all the info by itself, there might need to be context added for this to make sense.

It would be useful when debugging an application (or put another way; easier than current logging, when wanting to pinpoint a specific problem you're having somewhere in the code). At least this is the most common reason why people ask, AFAIK.

Edit: As yjeroen pointed out there's already a getText() on CDbCommand, so that part seems to be covered.
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,433
  • Joined: 17-January 09
  • Location:Russia

Posted 20 June 2012 - 04:13 AM

Yes, already in the code.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#3 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 20 June 2012 - 04:14 AM

View Postsamdark, on 20 June 2012 - 04:13 AM, said:

Yes, already in the code.

For what parts though, CDbCommand only? What about situations where you have a criteria and a data provider, or a criteria and want to do a find*() ?
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,433
  • Joined: 17-January 09
  • Location:Russia

Posted 20 June 2012 - 04:22 AM

In 2.0 DAO and AR are tightly integrated so I think that will work for both.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
1

#5 User is offline   rAWTAZ 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 08-January 10

Posted 20 June 2012 - 04:23 AM

Nice :) Looking forward to seeing some actual code.
0

#6 User is offline   Jaggi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 05-September 11

Posted 20 June 2012 - 11:25 AM

I was about to second this just today, yii really needs this. Current process of creating a syntax error so it prints it out sql in the error is kind of hacky :P. Yii Debugger owns tho.
See my development site @ www.CodeTheInter.net (BETA)

Posted Image Posted Image

Quote

If you make it idiot proof, they'll build a better idiot
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users