Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM date comparaison
  • 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
  • vLightvLight
    Accepted Answer
    since CURDATE() is a mysql's buildin function, you need to use \DB::expr('CURDATE()')for that


    try this:

    $spectacle = Model_Spectacle::find('first', array(
    'where' => array(array('date', '>=', \DB::expr('CURDATE()') )),
    'order_by' => array('date' => 'asc')
    ));
  • It works perfectly.

    Thank you very much :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion