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来弄清楚结束日期已被保留。