문제

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!

도움이 되었습니까?

해결책

Try this

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

다른 팁

$objectChanges = Table_model::update_all(array(
    'set' => array(
      'field_to_update' => 'Y'
    ),
    'conditions' => array(
      "sex= 'Male' && age <= 50"
    )
  )
);

for example if you have use and conditions you can use

event::all(array('conditions' => array('event_type = ? AND date = ?', 'opera', '06-06-2013')));

which produce sql

SELECT * FROM event WHERE event_type = 'pera' AND date = '06-06-2013';

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top