クライアント向けのレンタル Web サイトを構築するために codeigniter を使用しています。クエリに一致するレンタル期間がない場合にのみ 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;
}
私の問題のほとんどは私の頭の中にあると確信していますが、開始日から終了日までの期間がすでに予約されているかどうかを確認する必要があります。