I'm brand new to the framework, but I find myself a bit hung up with the error messages I get back while issuing mySQL stuff.
i.e.
CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined.
Is there a command I can use to get whatever my DB query would have been for debugging? Is there anything I'm missing?
Thanks
Page 1 of 1
DB Model - Debugging queries.
#2
Posted 21 April 2009 - 03:58 PM
Could you turn on logging and describe what is the SQL generated?
#3
Posted 29 April 2009 - 06:48 PM
Ahh, ok I figured it out.
Thanks qiang.
I basically made the query output when I had a query error which definatly helped me out.
I changed line 115 in CDbCommand to:
throw new CDbException(Yii::t('yii','CDbCommand failed to prepare the SQL statement: {error}' . $this->getText(),
Which adds my query to my log.
I'm not sure if this is the best way to handle it, but it really helped me out. If there is another way I 'should' be doing it please let me know.
I'm trying to really learn the framework, but when I don't really know the best way I find myself hacking through it.
Thanks.
Thanks qiang.
I basically made the query output when I had a query error which definatly helped me out.
I changed line 115 in CDbCommand to:
throw new CDbException(Yii::t('yii','CDbCommand failed to prepare the SQL statement: {error}' . $this->getText(),
Which adds my query to my log.
I'm not sure if this is the best way to handle it, but it really helped me out. If there is another way I 'should' be doing it please let me know.
I'm trying to really learn the framework, but when I don't really know the best way I find myself hacking through it.
Thanks.
#4
Posted 29 April 2009 - 07:45 PM
Quote
Ahh, ok I figured it out.
Thanks qiang.
I basically made the query output when I had a query error which definatly helped me out.
I changed line 115 in CDbCommand to:
throw new CDbException(Yii::t('yii','CDbCommand failed to prepare the SQL statement: {error}' . $this->getText(),
Which adds my query to my log.
I'm not sure if this is the best way to handle it, but it really helped me out. If there is another way I 'should' be doing it please let me know.
I'm trying to really learn the framework, but when I don't really know the best way I find myself hacking through it.
Thanks.
Thanks qiang.
I basically made the query output when I had a query error which definatly helped me out.
I changed line 115 in CDbCommand to:
throw new CDbException(Yii::t('yii','CDbCommand failed to prepare the SQL statement: {error}' . $this->getText(),
Which adds my query to my log.
I'm not sure if this is the best way to handle it, but it really helped me out. If there is another way I 'should' be doing it please let me know.
I'm trying to really learn the framework, but when I don't really know the best way I find myself hacking through it.
Thanks.
hmm, I think you hit the wrong way, you should never change the framework core code.
What Qiang was referring is to enable log component in config file, here is sample code:
You could find the sql in log by enabling 'CWebLogRoute'.
I wish this helps
Share this topic:
Page 1 of 1

Help












