[solved] using active records WHERE with now() - 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: [solved] using active records WHERE with now() (/showthread.php?tid=28491) |
[solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]Pale Rider[/eluser] Ok, I'm a bit stumped. This returns no rows: Code: function get_funerals() but if I open up phpMyAdmin and do: Code: SELECT * .. that returns the right results. Is AR doing some sort of escaping that's messing up that query. Not sure why that is not working :o cheers [solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]bretticus[/eluser] try printing the compiled query out to your browser: Code: function get_funerals() or turn on profiling to get a look: Code: function get_funerals() Oh by the way, when you return $query->result() you are just returning one row. [solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]Pale Rider[/eluser] hmmm well i did Code: function get_funerals() and it gave me Code: SELECT * FROM (`funerals`) WHERE `visitation` > 'NOW()' o_O result just returns one result? What should I be using? I have many queries such as Code: function get_orders_stage1() .. and they seem to be returning all the right rows. [solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]bretticus[/eluser] try Code: $this->db->where('visitation >', 'NOW()', TRUE); EDIT: Sorry, that would be FALSE instead of TRUE. If that doesn't work try: $this->db->where('visitation > NOW()'); [solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]Pale Rider[/eluser] Hmm, just tried Code: $this->db->where('visitation >', 'NOW()', TRUE); but no nice. I guess I can try doing a query(), just thought maybe it was something obvious with why AR wasn't giving me rows [solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]bretticus[/eluser] [quote author="Pale Rider" date="1268439558"] result just returns one result? What should I be using? I have many queries such as [/quote] Check out the example for result() in the manual. [solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]Pale Rider[/eluser] Ahh, thank you sir Just tried FALSE and it worked. I just looked up AR in the user guide, some how I missed Quote:If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. in there. Thanks for the help! cheers. [solved] using active records WHERE with now() - El Forum - 03-12-2010 [eluser]bretticus[/eluser] [quote author="Pale Rider" date="1268439784"]Hmm, just tried Code: $this->db->where('visitation >', 'NOW()', TRUE); but no nice. I guess I can try doing a query(), just thought maybe it was something obvious with why AR wasn't giving me rows [/quote] Read my edit above (it should have been FALSE not TRUE.) |