Check empty query - 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: Check empty query (/showthread.php?tid=28486) |
Check empty query - El Forum - 03-12-2010 [eluser]joke2k[/eluser] Hi, this is my firt post in this forum. I need a function that check if all sql command is empty (where, join... etc), before call $this->db->result(). For example: Code: ... what can i do? tnx Check empty query - El Forum - 03-12-2010 [eluser]danmontgomery[/eluser] Code: $query = $this->db->where('some_field', $some_value)->get(); You can of course combine those two if you don't need to check for both conditions separately. Code: if($query && $query->num_rows()) { Check empty query - El Forum - 03-12-2010 [eluser]joke2k[/eluser] hehehe sorry for my italian english!! I'll try to explain me better. I need the check , before that DB Library perform a db-query. Reading the source, i think that to do this, i must check many variables : Code: var $ar_select = array(); something like this: Code: ... extends DB_active_rec ... sounds good? Check empty query - El Forum - 03-12-2010 [eluser]danmontgomery[/eluser] Yep, looks like it. Check empty query - El Forum - 03-12-2010 [eluser]joke2k[/eluser] Final solution: Code: function is_empty_query() { i've put this code in my ORM library because cannot extends DB_active_rec. tnx for your time. |