Commit bf45643e authored by Estéban Ristich's avatar Estéban Ristich
Browse files

Fix SQL (error : interval check search in returned loans)

parent 4dacf181
......@@ -739,9 +739,9 @@ function get_loans_all_by_equipment_borrowed($pdo, $equipment_id) {
* @return false|array
*/
function get_loans_interval_by_id($pdo, $equipment_id, $from, $to) {
$sql = 'SELECT * FROM pret WHERE ((`emprunt` <= ? AND `retour` >= ?) AND `nom` = ?) OR ((`emprunt` <= ? AND `retour` >= ?) AND `nom` = ?) OR ((`emprunt` >= ? AND `retour` <= ?) AND `nom` = ?);';
$sql = 'SELECT * FROM pret WHERE (((`emprunt` <= ? AND `retour` >= ?) AND `nom` = ?) OR ((`emprunt` <= ? AND `retour` >= ?) AND `nom` = ?) OR ((`emprunt` >= ? AND `retour` <= ?) AND `nom` = ?)) AND status != ?;';
$stmt = $pdo->prepare($sql);
$stmt->execute(array($from, $from, $equipment_id, $to, $to, $equipment_id, $from, $to, $equipment_id));
$stmt->execute(array($from, $from, $equipment_id, $to, $to, $equipment_id, $from, $to, $equipment_id, STATUS_LOAN_RETURNED));
$result_fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($result_fetch) > 0)
return $result_fetch;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment