dblayer : add the hookpreread and the hookpostread

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2267 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-08-21 11:43:18 +00:00
parent 162629f214
commit cfa429df0f

View File

@@ -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