Where if - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Where if (/showthread.php?tid=72830) |
Where if - Srtymz - 02-16-2019 Excuse my bad English! How can i use if statement in where Codeigniter RE: Where if - Wouter60 - 02-16-2019 Tell us a bit more about the context. What do you want to do, and for what do you need where and if? RE: Where if - PaulD - 02-16-2019 You can just surround your query builder calls with your if statements. Take a query that gets users that are members and paid: PHP Code: $this->db->from('users'); Now you only want to check for paid if some variable is set, say $show_paid_only is true. PHP Code: $this->db->from('users'); If you are chaining your calls you just break the chain to insert the if statement. |