CodeIgniter Forums
Active Record: viewing the resulting queries? - 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: Active Record: viewing the resulting queries? (/showthread.php?tid=16104)



Active Record: viewing the resulting queries? - El Forum - 02-24-2009

[eluser]degu[/eluser]
Hello,

is there a way to view/log the queries that the active record methods build? I need to analyze some of my more complex queries for debugging purposes. Thanks!


Active Record: viewing the resulting queries? - El Forum - 02-24-2009

[eluser]simshaun[/eluser]
Try enabling the profiler. It should show the queries at the bottom.


Active Record: viewing the resulting queries? - El Forum - 02-24-2009

[eluser]fesweb[/eluser]
To be more specific for new people...

At the top of your function (or inside the controller's __construct() function):
Code:
$this->output->enable_profiler();



Active Record: viewing the resulting queries? - El Forum - 02-24-2009

[eluser]Armchair Samurai[/eluser]
You can also echo out the query with $this->db->last_query()