Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
ORM date comparaison
akimad
August 2014
Hello,
I want to get my first object whith his date > or = to current day. I've done this but it does'nt work :
$spectacle = Model_Spectacle::find('first', array(
'where' => array(array('date', '>=', 'CURDATE()')),
'order_by' => array('date' => 'asc')
));
I don't understand why it doesn't work..
Thank you in avdance for your help
vLight
August 2014
Accepted Answer
since CURDATE() is a mysql's buildin function, you need to use
\DB::expr('CURDATE()')
for that
http://fuelphp.com/docs/classes/database/db.html#/method_expr
try this:
$spectacle = Model_Spectacle::find('first', array(
'where' => array(array('date', '>=', \DB::expr('CURDATE()') )),
'order_by' => array('date' => 'asc')
));
akimad
August 2014
It works perfectly.
Thank you very much
:)
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
akimad
August 2014
vLight
August 2014