diff --git a/src/Dblayer.php b/src/Dblayer.php index b0805b9..28c269c 100644 --- a/src/Dblayer.php +++ b/src/Dblayer.php @@ -112,13 +112,14 @@ class Dblayer // Based on an idea of http://tonylandis.com/php/php5-pdo-singleton-class/ private static $instance = array (); - /** Connection to the database engine - * See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format - * @param string $dsn PDO Data Source Name - * @param string|null $username Username to connect - * @param string|null $password Password to connect - * @param string|null $driver_options Driver options to the database - */ + /** + * Connection to the database engine + * See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format + * @param string $dsn PDO Data Source Name + * @param string|null $username Username to connect + * @param string|null $password Password to connect + * @param string|null $driver_options Driver options to the database + */ public function __construct ($dsn, $username=null, $password=null, $driver_options=null) { @@ -232,8 +233,9 @@ class Dblayer return self::$instance[$this->dsn]; } - /** Return the connected database name from DSN used to connect - */ + /** + * Return the connected database name from DSN used to connect + */ public function databasename () { if ($this->sep === "") @@ -251,8 +253,9 @@ class Dblayer return NULL; } - /** Return all the tables available in the database - */ + /** + * Return all the tables available in the database + */ public function listTables () { if ($this->sep === "") @@ -295,11 +298,12 @@ class Dblayer return $res; } - /** Verify if the provided data can be inserted/updated in the database. - * @param array $data An array containing the data to verify with keys - * @param mixed|null $updatekey the key to update - * @return an array with the errors in array($key=>array($priority,$message)) - */ + /** + * Verify if the provided data can be inserted/updated in the database. + * @param array $data An array containing the data to verify with keys + * @param mixed|null $updatekey the key to update + * @return array an array with the errors in array($key=>array($priority,$message)) + */ public function verify ($data, $updatekey=false) { if ($this->debug) echo "== Entering verify\n"; @@ -692,21 +696,22 @@ class Dblayer return $lastID; } - /** Read the table content based on a select filter, ordered by order - * operator and the associated select value - * @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 boolean|null $whereOr The WHERE parameters are separated by OR - * instead of AND - * @param array|null $foreignSelect Add a filter on foreign keys - * @return array array ([0] => array (column=>value, column=>value),); - */ + /** + * Read the table content based on a select filter, ordered by order + * operator and the associated select value + * @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 boolean|null $whereOr The WHERE parameters are separated by OR + * instead of AND + * @param array|null $foreignSelect Add a filter on foreign keys + * @return array array ([0] => array (column=>value, column=>value),); + */ public function read ($select=null, $display=null, $order=null, $whereOr=false, $foreignSelect=null) { @@ -882,13 +887,14 @@ class Dblayer return $res; } - /** Update the key tuple with the provided data - * Return the number of rows modified - * @param string|integer $updatekey The key applied on primary key to be - * updated - * @param array $data The values to be updated - * @return the number of lines modified - */ + /** + * Update the key tuple with the provided data + * Return the number of rows modified + * @param string|integer $updatekey The key applied on primary key to be + * updated + * @param array $data The values to be updated + * @return integer the number of lines modified + */ public function update ($updatekey, $data) { if ($this->debug) echo "== Entering update\n"; @@ -1464,78 +1470,85 @@ class Dblayer } - /** 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 - */ + /** + * 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 - * @param array $data the data to insert in the database - * @return the modified data - */ + /** + * Hook preinsert + * This hook is run before inserting a new data in the database, after the + * verification + * @param array $data the data to insert in the database + * @return array the modified data + */ public function hookpreinsert ($data) { return $data; } - /** Hook postinsert - * This hook is run after successfuly insert a new data in the database - * @param array $data the data selected by the select - * @param integer $lastID the insert identifier - * @return the modified lastID - */ + /** + * Hook postinsert + * This hook is run after successfuly insert a new data in the database + * @param array $data the data selected by the select + * @param integer $lastID the insert identifier + * @return integer the modified lastID + */ public function hookpostinsert ($data, $lastID) { return $lastID; } - /** Hook preupdate - * This hook is run before updating a data in the database, after the - * verification - * @param string $updatekey the key to be modify - * @param array $data the data selected by the select - * @return the modified data - */ + /** + * Hook preupdate + * This hook is run before updating a data in the database, after the + * verification + * @param string $updatekey the key to be modify + * @param array $data the data selected by the select + * @return array the modified data + */ public function hookpreupdate ($updatekey, $data) { return $data; } - /** Hook postupdate - * This hook is run after successfuly update a data in the database - * @param string $updatekey the key which was modified - * @param array $data the data selected by the select - * @param integer $nbLinesUpdated The number of modified lines - * @return the modified $nbLinesUpdated - */ + /** + * Hook postupdate + * This hook is run after successfuly update a data in the database + * @param string $updatekey the key which was modified + * @param array $data the data selected by the select + * @param integer $nbLinesUpdated The number of modified lines + * @return integer the modified $nbLinesUpdated + */ public function hookpostupdate ($updatekey, $data, $nbLinesUpdated) { return $nbLinesUpdated; } - /** Hook predelete - * This hook is run before deleting a data in the database - * @param string $deletekey The key to be removed - * @return the modified $deletekey - */ + /** + * Hook predelete + * This hook is run before deleting a data in the database + * @param string $deletekey The key to be removed + * @return string the modified $deletekey + */ public function hookpredelete ($deletekey) { return $deletekey; } - /** Hook postdelete - * This hook is run after successfuly deleting a data in the database - * @param string $deletekey The removed key - * @param integer $nbLinesDeleted The number of deleted lines - * @return $nbLinesUpdated - */ + /** + * Hook postdelete + * This hook is run after successfuly deleting a data in the database + * @param string $deletekey The removed key + * @param integer $nbLinesDeleted The number of deleted lines + * @return integer $nbLinesUpdated + */ public function hookpostdelete ($deletekey, $nbLinesDeleted) { return $nbLinesDeleted;