Call to a member function real_escape_string() on null - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Call to a member function real_escape_string() on null (/showthread.php?tid=70776) |
Call to a member function real_escape_string() on null - thiago.bittencourt - 05-29-2018 I'm facing this error in my model function: Code: An uncaught Exception was encountered This is the function: PHP Code: public function getCompanyMessages($idCompany) The line 125 is PHP Code: $this->db->where($where); So I wrote an echo(var_export($where, true)); before this to get the content of $where array, and the content is just this: Code: array ( Why am I having this error and how to solve it? My environment is:
PHP Code: $active_group = 'default'; RE: Call to a member function real_esp - php_rocs - 05-29-2018 @thiago.bittencourt, Why don't you have CI print the query so that you can see it. This way you can see what generated query is being run. Here is the link: (The function that you need is $this->db->get_compiled_select()) https://www.codeigniter.com/userguide3/database/query_builder.html?highlight=get_compiled_select#selecting-data RE: Call to a member function real_esp - thiago.bittencourt - 05-30-2018 (05-29-2018, 12:36 PM)php_rocs Wrote: @thiago.bittencourt, I did it, and I got the query and ran in my MySQL editor, and it worked. So, to workaround this, I got the full query returned by $this->db->get_compiled_select() and ran into $this->db->query(): PHP Code: $query = $this->db->get_compiled_select(); And now it's working. |