![]() |
debugging Models - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: debugging Models (/showthread.php?tid=32485) |
debugging Models - El Forum - 07-25-2010 [eluser]jtan[/eluser] Is it possible to debug the Model in Codeigniter? I want to check whether the mistake is in the Controller or the Model, hence would like to get the result of the Models directly without loading the Views. debugging Models - El Forum - 07-26-2010 [eluser]Eric Barnes[/eluser] You can just echo, print_r, var_dump etc in the model. Or use unit testing. debugging Models - El Forum - 07-26-2010 [eluser]mddd[/eluser] Or you can use the log_message() function to write information to the log file. Code: log_message('debug', 'Some_model: value of $somevar: '. $somevar); debugging Models - El Forum - 07-26-2010 [eluser]Ngulo[/eluser] hi guys...i'm referring to this post cause i'm trying debugging with an echo a query like this: Code: $query = $this->db->select('id','ip','date') but it always returns me this error: Code: A PHP Error was encountered thanks debugging Models - El Forum - 07-26-2010 [eluser]Eric Barnes[/eluser] Try this: Code: echo $this->db->last_query(); debugging Models - El Forum - 07-26-2010 [eluser]danmontgomery[/eluser] You're never executing the query. from() doesn't return a compiled query, it returns the database object. You need to execute the query with get() or get_where() first. Also, select() fields aren't individual parameters, they should all be one: Code: select('id,ip,date') Code: select('id','ip','date') user guide debugging Models - El Forum - 07-26-2010 [eluser]Eric Barnes[/eluser] [quote author="noctrum" date="1280185555"]You're never executing the query. from() doesn't return a compiled query, it returns the database object.[/quote] Good catch! ![]() Code: $query = $this->db->get(); debugging Models - El Forum - 07-28-2010 [eluser]Ngulo[/eluser] thanks guys i will try ![]() debugging Models - El Forum - 07-28-2010 [eluser]pickupman[/eluser] Even better try: Code: $this->output->enable_profiler(TRUE); Get execution time, memory, $_REQUEST array, all sql queries with query times. debugging Models - El Forum - 07-29-2010 [eluser]Ngulo[/eluser] yeah perfect man this is nicer ![]() |