From 9aa5c8dcc72c5163f1b3bcd2e1c16ab5077d7a59 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 12 Mar 2015 20:10:16 +0000 Subject: [PATCH] routeSQL : search can now start with a ^ or finished by a dollar to simulate a regex git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2019 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- routeSQL.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/routeSQL.php b/routeSQL.php index cad2294..b139839 100644 --- a/routeSQL.php +++ b/routeSQL.php @@ -306,7 +306,18 @@ class routeSQL { $criteria = array (); foreach (array_keys($titles) as $column) - $criteria[] = array ($column, "%$search%", "LIKE"); + { + $s = $search; + if ($search[0] === "^") + $s = substr ($s, 1); + else + $s = "%$s"; + if (substr ($search, -1) === "$") + $s = substr ($s, 0, -1); + else + $s = "$s%"; + $criteria[] = array ($column, "$s", "LIKE"); + } $datas = $this->objectDB->read ($criteria, null, null, true); } $nbentries = count ($datas);