CodeIgniter Forums
DB Query error logs not showing the script name - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: DB Query error logs not showing the script name (/showthread.php?tid=65810)



DB Query error logs not showing the script name - karthik_code - 07-27-2016

For example I got the following error in log file.

Quote:ERROR - 2016-07-27 10:19:43 --> Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 - Invalid query: select status as value from users where regid =

The above query is called from many controllers, so I wish to know the script name / controller / URI which produces the above error.
Is there any work around to improve the CI error logging?


RE: DB Query error logs not showing the script name - InsiteFX - 07-27-2016

PHP Code:
if ( ! $this->db->simple_query('SELECT `example_field` FROM `example_table`'))
{
 
       $error $this->db->error(); // Has keys 'code' and 'message'


Get the last error.


RE: DB Query error logs not showing the script name - Narf - 07-28-2016

(07-27-2016, 07:05 AM)karthik_code Wrote: For example I got the following error in log file.

Quote:ERROR - 2016-07-27 10:19:43 --> Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 - Invalid query: select status as value from users where regid =

The above query is called from many controllers, so I wish to know the script name / controller / URI which produces the above error.
Is there any work around to improve the CI error logging?

This is what happens when you don't do abstractions. Properly structured code would enable you to easily find the error.


RE: DB Query error logs not showing the script name - karthik_code - 08-06-2016

Thanks