2
我使用codeigniter爲客戶建立租賃網站。我試圖只在沒有租期符合我的查詢時才返回true。基本上有一個開始日期和結束日期的租賃表。Codeigniter:如果日期不在2個值之間,則返回true
我的客戶從日期選擇器中選擇一個開始日期,結束日期是開始日期之後的一組天數。
所以我想知道在這些日期是否有任何出租物品正在出租以驗證客戶是否可以預訂物品。這裏是我到目前爲止,我需要用Codeigniters活動記錄來完成這個...
function check_product($periodLength) {
//This is the start time they chose from the picker
$startTime = $_POST['date'];
//The period length is a variable of days, so the end date would be their chosen start date plus a certain amount of days...
$endTime = strtotime('+'.$periodLength.'day', $startTime);
$this->db->where('productsId', $_POST['productId']);
//This is where I need help!!! What query would give me records that are NOT between the start and end dates that i'm wanting
$query = $this->db->get('rentals');
$data = array();
foreach ($query->result() as $row) {
$data[] = array(
'id' => $row->id,
'customerId' => $row->customerId,
'productsId' => $row->productsId,
'periodStart' => $row->periodStart,
'periodEnd' => $row->periodEnd,
'status' => $row->status,
'specialInstructions' => $row->specialInstructions,
'adminNotes' => $row->adminNotes
);
}
return $data;
}
我的大部分問題,只是在我的頭,我敢肯定,但我需要,如果我的STARTDATE來弄清楚結束日期已被保留。