CodeIgniter Forums
Where to look for an SQL string? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Where to look for an SQL string? (/showthread.php?tid=16565)



Where to look for an SQL string? - El Forum - 03-10-2009

[eluser]Bikun[/eluser]
How could I get to know in which file and line is error occurred?

Error is as follows, but it's REALLY difficult to figure out the exact file where I should make changes:
Code:
A Database Error Occurred

Error Number: 1054

Unknown column 'is_author' in 'where clause'

SELECT FORMAT(AVG(price), 0) AS average_price FROM (users) WHERE `is_client` = 1



Where to look for an SQL string? - El Forum - 03-10-2009

[eluser]Colin Williams[/eluser]
It should be happening in the model.


Where to look for an SQL string? - El Forum - 03-10-2009

[eluser]Bikun[/eluser]
I don't use models ... It's happening in controller. It's not a big issue to find where, but it would be much easier if I could see the exact file and line near that error. Is it possible to configure it somehow in an east way?


Where to look for an SQL string? - El Forum - 03-10-2009

[eluser]Colin Williams[/eluser]
Well, it's MySQL generating the error, not PHP. So there's no way it could know the line number, file, etc.


Where to look for an SQL string? - El Forum - 03-10-2009

[eluser]TheFuzzy0ne[/eluser]
Run a file search for the word "FORMAT" (case-sensitive) within the file contents.

On a Linux server, cd into your application directory, and fire this command:

grep -r "FORMAT" ./


Where to look for an SQL string? - El Forum - 03-10-2009

[eluser]kevinprince[/eluser]
Are you using active record or even if your

do echo $this->db->last_query();

paste what you get in here along with the php code your using to generate the query.