How to echo statement of query with Active Record |
Hello,
how can I echo the statement of a query when I use code as this? PHP Code: $this->db->from($this->table); thank you (02-15-2016, 02:05 AM)SDir Wrote: Hello, Use : PHP Code: echo $this->db->last_query(); Other usefull query utilities : http://www.codeigniter.com/user_guide/da...ert_string (02-15-2016, 02:21 AM)XMadMax Wrote:(02-15-2016, 02:05 AM)SDir Wrote: Hello, Thank You for your answer. But I can't use last_query() because of this unsolved probem (working with Oracle): http://forum.codeigniter.com/thread-64340.html For example: if I write this code, I get no output from last_query(): PHP Code: $this->db->from($this->table); So, I'm looking for a different method to print the statement. Thank You
02-15-2016, 03:15 AM
(This post was last modified: 02-15-2016, 03:17 AM by Avenirer. Edit Reason: ...maybe a select() method too... )
A query is generated only if... you generate it...
The from() ("$this->db->from($this->table);") method is not generating a query by itself. You must also have a result generating function like, for example, a "get()" method. So, if you want to have the last_query(), you must have: PHP Code: $this->db->select('*'); ...or, even simpler...: PHP Code: $this->db->get($this->table); Website: http://avenir.ro
...or use get_compiled_select() https://codeigniter.com/user_guide/datab...led_select
PHP Code: $this->db->from($this->table); |
Welcome Guest, Not a member yet? Register Sign In |