Dblayer : set the @return with a type

This commit is contained in:
2022-07-22 10:10:23 +02:00
parent e9dea5b890
commit d68e0ac9c1

View File

@@ -112,7 +112,8 @@ class Dblayer
// Based on an idea of http://tonylandis.com/php/php5-pdo-singleton-class/ // Based on an idea of http://tonylandis.com/php/php5-pdo-singleton-class/
private static $instance = array (); private static $instance = array ();
/** Connection to the database engine /**
* Connection to the database engine
* See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format * See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format
* @param string $dsn PDO Data Source Name * @param string $dsn PDO Data Source Name
* @param string|null $username Username to connect * @param string|null $username Username to connect
@@ -232,7 +233,8 @@ class Dblayer
return self::$instance[$this->dsn]; 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 () public function databasename ()
{ {
@@ -251,7 +253,8 @@ class Dblayer
return NULL; return NULL;
} }
/** Return all the tables available in the database /**
* Return all the tables available in the database
*/ */
public function listTables () public function listTables ()
{ {
@@ -295,10 +298,11 @@ class Dblayer
return $res; return $res;
} }
/** Verify if the provided data can be inserted/updated in the database. /**
* 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 array $data An array containing the data to verify with keys
* @param mixed|null $updatekey the key to update * @param mixed|null $updatekey the key to update
* @return an array with the errors in array($key=>array($priority,$message)) * @return array an array with the errors in array($key=>array($priority,$message))
*/ */
public function verify ($data, $updatekey=false) public function verify ($data, $updatekey=false)
{ {
@@ -692,7 +696,8 @@ class Dblayer
return $lastID; return $lastID;
} }
/** Read the table content based on a select filter, ordered by order /**
* Read the table content based on a select filter, ordered by order
* operator and the associated select value * operator and the associated select value
* @param array|null $select Rows to select with * @param array|null $select Rows to select with
* $select = array (array ($key, $val, $operator), ...) * $select = array (array ($key, $val, $operator), ...)
@@ -882,12 +887,13 @@ class Dblayer
return $res; return $res;
} }
/** Update the key tuple with the provided data /**
* Update the key tuple with the provided data
* Return the number of rows modified * Return the number of rows modified
* @param string|integer $updatekey The key applied on primary key to be * @param string|integer $updatekey The key applied on primary key to be
* updated * updated
* @param array $data The values to be updated * @param array $data The values to be updated
* @return the number of lines modified * @return integer the number of lines modified
*/ */
public function update ($updatekey, $data) public function update ($updatekey, $data)
{ {
@@ -1464,7 +1470,8 @@ class Dblayer
} }
/** Hook postread /**
* Hook postread
* This hook is run after selecting the data. * This hook is run after selecting the data.
* @param array $data the data selected by the select * @param array $data the data selected by the select
* @return array The data modified by the hook * @return array The data modified by the hook
@@ -1474,67 +1481,73 @@ class Dblayer
return $data; return $data;
} }
/** Hook preinsert /**
* Hook preinsert
* This hook is run before inserting a new data in the database, after the * This hook is run before inserting a new data in the database, after the
* verification * verification
* @param array $data the data to insert in the database * @param array $data the data to insert in the database
* @return the modified data * @return array the modified data
*/ */
public function hookpreinsert ($data) public function hookpreinsert ($data)
{ {
return $data; return $data;
} }
/** Hook postinsert /**
* Hook postinsert
* This hook is run after successfuly insert a new data in the database * This hook is run after successfuly insert a new data in the database
* @param array $data the data selected by the select * @param array $data the data selected by the select
* @param integer $lastID the insert identifier * @param integer $lastID the insert identifier
* @return the modified lastID * @return integer the modified lastID
*/ */
public function hookpostinsert ($data, $lastID) public function hookpostinsert ($data, $lastID)
{ {
return $lastID; return $lastID;
} }
/** Hook preupdate /**
* Hook preupdate
* This hook is run before updating a data in the database, after the * This hook is run before updating a data in the database, after the
* verification * verification
* @param string $updatekey the key to be modify * @param string $updatekey the key to be modify
* @param array $data the data selected by the select * @param array $data the data selected by the select
* @return the modified data * @return array the modified data
*/ */
public function hookpreupdate ($updatekey, $data) public function hookpreupdate ($updatekey, $data)
{ {
return $data; return $data;
} }
/** Hook postupdate /**
* Hook postupdate
* This hook is run after successfuly update a data in the database * This hook is run after successfuly update a data in the database
* @param string $updatekey the key which was modified * @param string $updatekey the key which was modified
* @param array $data the data selected by the select * @param array $data the data selected by the select
* @param integer $nbLinesUpdated The number of modified lines * @param integer $nbLinesUpdated The number of modified lines
* @return the modified $nbLinesUpdated * @return integer the modified $nbLinesUpdated
*/ */
public function hookpostupdate ($updatekey, $data, $nbLinesUpdated) public function hookpostupdate ($updatekey, $data, $nbLinesUpdated)
{ {
return $nbLinesUpdated; return $nbLinesUpdated;
} }
/** Hook predelete /**
* Hook predelete
* This hook is run before deleting a data in the database * This hook is run before deleting a data in the database
* @param string $deletekey The key to be removed * @param string $deletekey The key to be removed
* @return the modified $deletekey * @return string the modified $deletekey
*/ */
public function hookpredelete ($deletekey) public function hookpredelete ($deletekey)
{ {
return $deletekey; return $deletekey;
} }
/** Hook postdelete /**
* Hook postdelete
* This hook is run after successfuly deleting a data in the database * This hook is run after successfuly deleting a data in the database
* @param string $deletekey The removed key * @param string $deletekey The removed key
* @param integer $nbLinesDeleted The number of deleted lines * @param integer $nbLinesDeleted The number of deleted lines
* @return $nbLinesUpdated * @return integer $nbLinesUpdated
*/ */
public function hookpostdelete ($deletekey, $nbLinesDeleted) public function hookpostdelete ($deletekey, $nbLinesDeleted)
{ {