Hi i want to search data from MySql table with This Week, This month, This Year..
Below is my Controller Code.
I am not getting any data with Current DATE_SUB(NOW(), INTERVAL 1 WEEK
Controller initial Code:
$condition = array('Order.eventid' => $id, 'Order.userid !=' => '');
if (isset($_GET['dr']) && !empty($_GET['dr'])) {
if ($_GET['dr'] == 2) { // This week
$condition['Order.addeddate'] = 'DATE_SUB(NOW(), INTERVAL 1 WEEK)';
}
if ($_GET['dr'] == 3) { // This month
$condition['Order.addeddate'] = 'DATE_SUB(NOW(), INTERVAL 1 MONTH)';
}
if ($_GET['dr'] == 4) { // This year
$condition['Order.addeddate'] = 'DATE_SUB(NOW(), INTERVAL 1 YEAR)';
}
if ($_GET['dr'] == 5) { // Custom date range
//$condition[] = array('Order.addeddate' => 'DATE_SUB(NOW(), INTERVAL 1 MONTH)');
}
}
if (isset($_GET['ot']) && !empty($_GET['ot'])) {
if ($_GET['ot'] == 'attending') { //attending
$condition['Order.orderstatus'] = '1';
}
if ($_GET['ot'] == 'processing') { //online_sales
$condition['Order.orderstatus'] = '2';
}
if ($_GET['ot'] == 'manual') { //manual
$condition['Order.orderstatus'] = '1';
}
if ($_GET['ot'] == 'refunded') { //refunded
$condition['Order.orderstatus'] = '1';
}
}
$this->paginate = array(
'conditions' => $condition
);