From bbde7e00eeda22ff2d01671470e2e4956276a855 Mon Sep 17 00:00:00 2001 From: MatMasIt Date: Mon, 8 Nov 2021 23:52:07 +0100 Subject: [PATCH] Search is now cases insesitive and space trim tolerant --- server/results.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/results.php b/server/results.php index 7d83268..d59fca2 100644 --- a/server/results.php +++ b/server/results.php @@ -71,7 +71,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Titolo LIKE ('%' || :Titolo || '%')"; + $query .= " trim(lower(Titolo)) LIKE ('%' || trim(lower(:Titolo)) || '%')"; $arrayQ[":Titolo"] = $_POST["Titolo"]; } if (!empty($_POST["Letter"])) { @@ -80,7 +80,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Titolo LIKE (:Letter || '%')"; + $query .= " trim(lower(Titolo)) LIKE ( trim(lower(:Letter)) || '%')"; $arrayQ[":Letter"] = $_POST["Letter"]; } if (!empty($_POST["Autore"])) { @@ -89,7 +89,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Autore LIKE ('%' || :Autore || '%')"; + $query .= " trim(lower(Autore)) LIKE ('%' || trim(lower(:Autore)) || '%')"; $arrayQ[":Autore"] = $_POST["Autore"]; } if (!empty($_POST["Editore"])) { @@ -98,7 +98,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Editore LIKE ('%' || :Editore || '%')"; + $query .= " trim(lower(Editore)) LIKE ('%' || trim(lower(:Editore)) || '%')"; $arrayQ[":Editore"] = $_POST["Editore"]; } if (!empty($_POST["Genere"])) { @@ -107,7 +107,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Genere LIKE ('%' || :Genere || '%')"; + $query .= " trim(lower(Genere)) LIKE ('%' || trim(lower(:Genere)) || '%')"; $arrayQ[":Genere"] = $_POST["Genere"]; } if (!empty($_POST["ISBN"])) { @@ -116,7 +116,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " ISBN LIKE ('%' || :ISBN || '%')"; + $query .= " trim(lower(ISBN)) LIKE ('%' || trim(lower(:ISBN)) || '%')"; $arrayQ[":ISBN"] = $_POST["ISBN"]; } if (!empty($_POST["Inventario"])) { @@ -125,7 +125,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Inventario LIKE ('%' || :Inventario || '%')"; + $query .= " trim(lower(Inventario)) LIKE ('%' || trim(lower(:Inventario)) || '%')"; $arrayQ[":Inventario"] = $_POST["Inventario"]; } if (!empty($_POST["Serie"])) { @@ -134,7 +134,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Serie LIKE ('%' || :Serie || '%')"; + $query .= " trim(lower(Serie)) LIKE ('%' || trim(lower(:Serie)) || '%')"; $arrayQ[":Serie"] = $_POST["Serie"]; } if (!empty($_POST["Lingua"])) { @@ -143,7 +143,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Lingua LIKE ('%' || :Lingua || '%')"; + $query .= "trim(lower(Lingua)) LIKE ('%' || trim(lower(:Lingua)) || '%')"; $arrayQ[":Lingua"] = $_POST["Lingua"]; } if (!empty($_POST["Argomento"])) { @@ -152,7 +152,7 @@ function main($pdo, $pageN) } else { $query .= " AND "; } - $query .= " Argomento LIKE ('%' || :Argomento || '%')"; + $query .= " trim(lower(Argomento)) LIKE ('%' || trim(lower(:Argomento)) || '%')"; $arrayQ[":Argomento"] = $_POST["Argomento"]; } if ($_POST["Prestito"] == "P") { @@ -334,6 +334,6 @@ function main($pdo, $pageN)