Мой клиент выбирает дату начала из средства выбора даты, а дата окончания — это заданное количество дней после даты начала.
Поэтому я хочу узнать, сдаются ли какие-либо предметы аренды в эти даты, чтобы проверить, может ли клиент зарезервировать этот предмет. Вот что у меня есть на данный момент, и мне нужно сделать это с помощью активной записи 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;
}
Подробнее здесь: https://stackoverflow.com/questions/149 ... n-2-values
Мобильная версия