DomCI : Update all the PHPDoc
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3279 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
215
dblayer.php
215
dblayer.php
@@ -111,11 +111,12 @@ class dblayer
|
||||
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 */
|
||||
* 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)
|
||||
{
|
||||
@@ -229,7 +230,8 @@ 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 === "")
|
||||
@@ -247,7 +249,8 @@ 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 === "")
|
||||
@@ -291,9 +294,9 @@ class dblayer
|
||||
}
|
||||
|
||||
/** 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))
|
||||
* @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))
|
||||
*/
|
||||
public function verify ($data, $updatekey=false)
|
||||
{
|
||||
@@ -589,7 +592,8 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Insert a new line of data in the table. Datas must be an indexed array
|
||||
@param array $data Datas to be recorded (column=>value)*/
|
||||
* @param array $data Datas to be recorded (column=>value)
|
||||
*/
|
||||
public function insert ($data)
|
||||
{
|
||||
if ($this->debug) echo "== Entering insert\n";
|
||||
@@ -867,11 +871,12 @@ class dblayer
|
||||
}
|
||||
|
||||
/** 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 */
|
||||
* 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
|
||||
*/
|
||||
public function update ($updatekey, $data)
|
||||
{
|
||||
if ($this->debug) echo "== Entering update\n";
|
||||
@@ -971,8 +976,9 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Delete a tuple identified by its primary key
|
||||
Return the number of deleted rows (can be 0 !)
|
||||
@param string|integer $deletekey The key of primary key to be deleted */
|
||||
* Return the number of deleted rows (can be 0 !)
|
||||
* @param string|integer $deletekey The key of primary key to be deleted
|
||||
*/
|
||||
public function delete ($deletekey)
|
||||
{
|
||||
if ($this->debug) echo "== Entering delete\n";
|
||||
@@ -1004,7 +1010,8 @@ class dblayer
|
||||
return $nbLinesDeleted;
|
||||
}
|
||||
|
||||
/** Translation of fields */
|
||||
/** Translation of fieldsi
|
||||
*/
|
||||
public function titles ()
|
||||
{
|
||||
if ($this->debug) echo "== Entering titles\n";
|
||||
@@ -1024,7 +1031,8 @@ class dblayer
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/** Drop the table */
|
||||
/** Drop the table
|
||||
*/
|
||||
public function dropTable ()
|
||||
{
|
||||
if ($this->debug) echo "== Entering dropTables\n";
|
||||
@@ -1040,21 +1048,21 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Create the table defined by the differents fields.
|
||||
Define the SQL syntax based on SQL engines
|
||||
$table = "dns zones";
|
||||
$fields = array (
|
||||
"id"=>array ("integer", "not null", "autoincrement"),
|
||||
"zo ne"=>array ("varchar", "255", "not null"),
|
||||
"vie wname"=>array ("varchar", "255"),
|
||||
"view clients"=>array ("varchar", "255"),
|
||||
"comme nt"=>array ("varchar", "1024"),
|
||||
"opendate"=>array ("datetime", "not null"),
|
||||
"closedate"=>array ("datetime"),
|
||||
);
|
||||
$primary = "id";
|
||||
$unique = array ("id", array ("zo ne", "vie wname"));
|
||||
$foreign = array ("zone"=>"table.field",...);
|
||||
*/
|
||||
* Define the SQL syntax based on SQL engines
|
||||
* $table = "dns zones";
|
||||
* $fields = array (
|
||||
* "id"=>array ("integer", "not null", "autoincrement"),
|
||||
* "zo ne"=>array ("varchar", "255", "not null"),
|
||||
* "vie wname"=>array ("varchar", "255"),
|
||||
* "view clients"=>array ("varchar", "255"),
|
||||
* "comme nt"=>array ("varchar", "1024"),
|
||||
* "opendate"=>array ("datetime", "not null"),
|
||||
* "closedate"=>array ("datetime"),
|
||||
* );
|
||||
* $primary = "id";
|
||||
* $unique = array ("id", array ("zo ne", "vie wname"));
|
||||
* $foreign = array ("zone"=>"table.field",...);
|
||||
*/
|
||||
public function createTable ()
|
||||
{
|
||||
if ($this->debug) echo "== Entering createTable\n";
|
||||
@@ -1366,7 +1374,9 @@ class dblayer
|
||||
}
|
||||
|
||||
/** This function permit to send a SQL request to the database to do a SELECT
|
||||
Return the an array with the data */
|
||||
* Return the an array with the data
|
||||
* @param string $sql A valid SQL request to be execute
|
||||
*/
|
||||
public function directRead ($sql)
|
||||
{
|
||||
if ($this->debug) echo "== Entering directRead\n";
|
||||
@@ -1381,50 +1391,58 @@ class dblayer
|
||||
}
|
||||
|
||||
/** This function disconnect the database. It is normally only used in phpunit
|
||||
unit tests */
|
||||
* unit tests
|
||||
*/
|
||||
public function disconnect ()
|
||||
{
|
||||
unset (self::$instance[$this->dsn]);
|
||||
}
|
||||
|
||||
/** The prepare method */
|
||||
/** The prepare method
|
||||
* @param string $statement The valid template to be replaced
|
||||
* @param array|null $driver_options The replacement to be done
|
||||
*/
|
||||
public function prepare ($statement, $driver_options = array())
|
||||
{
|
||||
return self::$instance[$this->dsn]->prepare ($statement, $driver_options);
|
||||
}
|
||||
|
||||
/** Start a new Transaction */
|
||||
/** Start a new Transaction
|
||||
*/
|
||||
public function beginTransaction ()
|
||||
{
|
||||
return self::$instance[$this->dsn]->beginTransaction ();
|
||||
}
|
||||
|
||||
/** Commit (validate) a transaction */
|
||||
/** Commit (validate) a transaction
|
||||
*/
|
||||
public function commit ()
|
||||
{
|
||||
return self::$instance[$this->dsn]->commit ();
|
||||
}
|
||||
|
||||
/** RollBack a transaction */
|
||||
/** RollBack a transaction
|
||||
*/
|
||||
public function rollback ()
|
||||
{
|
||||
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 boolean|null &$whereOr The WHERE parameters are separated by OR
|
||||
instead of AND
|
||||
@param array|null &$foreignSelect Add a filter on foreign keys */
|
||||
* 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 boolean|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)
|
||||
{
|
||||
@@ -1432,60 +1450,77 @@ 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 */
|
||||
* 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 the data to insert in the database
|
||||
@return the modified data */
|
||||
* 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
|
||||
*/
|
||||
public function hookpreinsert ($data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** Hook postinsert
|
||||
This hook is run after successfuly insert a new data in the database
|
||||
@return the modified lastID */
|
||||
* 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
|
||||
*/
|
||||
public function hookpostinsert ($data, $lastID)
|
||||
{
|
||||
return $lastID;
|
||||
}
|
||||
|
||||
/** Hook preupdate
|
||||
This hook is run before updating a data in the database, after the
|
||||
verification
|
||||
@return the modified data */
|
||||
* 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
|
||||
*/
|
||||
public function hookpreupdate ($updatekey, $data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** Hook postupdate
|
||||
This hook is run after successfuly update a data in the database
|
||||
@return the modified $nbLinesUpdated */
|
||||
* 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
|
||||
*/
|
||||
public function hookpostupdate ($updatekey, $data, $nbLinesUpdated)
|
||||
{
|
||||
return $nbLinesUpdated;
|
||||
}
|
||||
|
||||
/** Hook predelete
|
||||
This hook is run before deleting a data in the database
|
||||
@return the modified $deletekey */
|
||||
* This hook is run before deleting a data in the database
|
||||
* @param string $deletekey The key to be removed
|
||||
* @return the modified $deletekey
|
||||
*/
|
||||
public function hookpredelete ($deletekey)
|
||||
{
|
||||
return $deletekey;
|
||||
}
|
||||
|
||||
/** Hook postdelete
|
||||
This hook is run after successfuly deleting a data in the database
|
||||
@return $nbLinesUpdated */
|
||||
* 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
|
||||
*/
|
||||
public function hookpostdelete ($deletekey, $nbLinesDeleted)
|
||||
{
|
||||
return $nbLinesDeleted;
|
||||
@@ -1494,63 +1529,81 @@ class dblayer
|
||||
///////////////////
|
||||
/// SETTERS ///
|
||||
///////////////////
|
||||
/** Set the table property */
|
||||
/** Set the table property
|
||||
* @param string $table The table name to use
|
||||
*/
|
||||
public function tableSet ($table)
|
||||
{
|
||||
$this->table = $table;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the tableprefix property */
|
||||
/** Set the tableprefix property
|
||||
* @param string $tableprefix The prefix to add in table names
|
||||
*/
|
||||
public function tableprefixSet ($tableprefix)
|
||||
{
|
||||
$this->tableprefix = $tableprefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the fields property */
|
||||
/** Set the fields property
|
||||
* @param array $fields Set the definition of the fields
|
||||
*/
|
||||
public function fieldsSet ($fields)
|
||||
{
|
||||
$this->fields = $fields;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the primary property */
|
||||
/** Set the primary property
|
||||
* @param string $primary The primary field
|
||||
*/
|
||||
public function primarySet ($primary)
|
||||
{
|
||||
$this->primary = $primary;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the unique property */
|
||||
/** Set the unique property
|
||||
* @param array $unique The array of the unique contraints
|
||||
*/
|
||||
public function uniqueSet ($unique)
|
||||
{
|
||||
$this->unique = $unique;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the foreign property */
|
||||
/** Set the foreign property
|
||||
* @param array $foreign The foreign array
|
||||
*/
|
||||
public function foreignSet ($foreign)
|
||||
{
|
||||
$this->foreign = $foreign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the debug property */
|
||||
/** Set the debug property
|
||||
* @param integer $debug The debug value
|
||||
*/
|
||||
public function debugSet ($debug)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the dsn property */
|
||||
/** Set the dsn property
|
||||
* @param string $dsn The DSN to use
|
||||
*/
|
||||
public function dsnSet ($dsn)
|
||||
{
|
||||
$this->dsn = $dsn;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the titles property */
|
||||
/** Set the titles property
|
||||
* @param array $titles The titles of the fields
|
||||
*/
|
||||
public function titlesSet ($titles)
|
||||
{
|
||||
$this->titles = $titles;
|
||||
|
||||
Reference in New Issue
Block a user