我正在尝试在php ActiveRecord
中绑定多个条件如何更改以下代码(有效)以绑定其他条件?
$events = Event::find('all', array(
'conditions' => array('event_type = ?', array('opera')),
'select' => 'col1, col2, col3',
));
谢谢!
答案 0 :(得分:4)
试试这个
$events = Event::find('all', array(
'conditions' => array('event_type = ? AND event_hour = ?', 'opera', 'your_event_hour'),
'select' => 'col1, col2, col3',
));
答案 1 :(得分:0)
$objectChanges = Table_model::update_all(array(
'set' => array(
'field_to_update' => 'Y'
),
'conditions' => array(
"sex= 'Male' && age <= 50"
)
)
);
答案 2 :(得分:-1)
例如,如果您有使用和条件,则可以使用
event::all(array('conditions' => array('event_type = ? AND date = ?', 'opera', '06-06-2013')));
生成sql
SELECT * FROM event
WHERE event_type ='pera'AND date = '06 -06-2013';