我有一个带有'birthdate'列的mysql'contact'表。 如何从今天起1周内获得生日联系人列表。
$sideBarTaskSuggestion = $this->Project->Contact->find('all', array(
'conditions' => array(
'Contact.group_id' => $this->Session->read('Auth.User.group_id'),
'Contact.birthdate NOT' => null,
'Contact.birthdate => ???1weekrange???
),
)
);
答案 0 :(得分:0)
您想要创建复合条件:
$sideBarTaskSuggestion = $this->Project->Contact->find('all', array(
'conditions' => array(
'Contact.group_id' => $this->Session->read('Auth.User.group_id'),
'Contact.birthdate NOT' => null,
'AND' => array(
array('Contact.birthdate NOT' => null),
array('Contact.birthdate <=' => date('Y-m-d', strtotime('+1 week'))),
array('Contact.birthdate >=' => date('Y-m-d')),
)
));