From cfa429df0fe08c300c15d481e7c5564b35426437 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 21 Aug 2015 11:43:18 +0000 Subject: [PATCH] dblayer : add the hookpreread and the hookpostread git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2267 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayer.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/dblayer.php b/dblayer.php index 1643c27..8acd339 100644 --- a/dblayer.php +++ b/dblayer.php @@ -691,6 +691,7 @@ class dblayer foreach ($foreignSelect as $s) $foreignSelectCols[] = $s[0]; } + $this->hookpreread ($select, $display, $order, $whereOr, $foreignSelect); $req = "SELECT $this->sep"; $req .= implode ("$this->sep,$this->sep", $display); $req .= "$this->sep "; @@ -799,6 +800,7 @@ class dblayer $res = array (); while ($d = $st->fetch (PDO::FETCH_ASSOC)) $res[] = $d; + $res = $this->hookpostread ($res); return $res; } @@ -1317,6 +1319,35 @@ class dblayer return self::$instance[$this->dsn]->rollback (); } + /** Hook preread + This hook is run before selecting the data in the database, after the + verification + @param array|null &$select Rows to select with + $select = array (array ($key, $val, $operator), ...) + $key=>column, $val=>value to found, $operator=>'LIKE', =... + @param array|null &$display Columns displayed + $display = array ($col1, $col2...); + @param array|null &$order Sort the columns by orientation + $order = array (array ($key, $orientation), ...) + $key=>column, $orientation=ASC/DESC + @param bool|null &$whereOr The WHERE parameters are separated by OR + instead of AND + @param array|null &$foreignSelect Add a filter on foreign keys */ + public function hookpreread (&$select, &$display, &$order, &$whereOr, + &$foreignSelect) + { + + } + + /** Hook postread + This hook is run after selecting the data. + @param array $data the data selected by the select + @return array The data modified by the hook */ + public function hookpostread ($data) + { + return $data; + } + /** Hook preinsert This hook is run before inserting a new data in the database, after the verification