Search code examples
phpactiverecordphpactiverecord

PHP ActiveRecord: How do I add multiple conditions?


I'm trying to bind more than one condition in php ActiveRecord

How can I change the below code (which works) to bind another condition?

$events = Event::find('all', array(
    'conditions' => array('event_type = ?', array('opera')),
    'select' => 'col1, col2, col3',
));

Thanks!


Solution

  • Try this

    $events = Event::find('all', array(
        'conditions' => array('event_type = ? AND event_hour = ?', 'opera', 'your_event_hour'),
        'select' => 'col1, col2, col3',
    ));