[ Index ] |
|
Code source de Dolibarr 2.0.1 |
[Code source] [Imprimer] [Statistiques]
DB_common is a base class for DB implementations, and must be inherited by all such.
Poids: | 1398 lignes (40 kb) |
Inclus ou requis: | 0 fois |
Référencé: | 0 fois |
Nécessite: | 0 fichiers |
DB_common:: (42 méthodes):
toString()
DB_common()
quoteString()
quote()
provides()
errorCode()
errorMessage()
raiseError()
setFetchMode()
setOption()
getOption()
prepare()
autoPrepare()
autoExecute()
buildManipSQL()
execute()
executeEmulateQuery()
executeMultiple()
freePrepared()
modifyQuery()
modifyLimitQuery()
query()
limitQuery()
getOne()
getRow()
getCol()
getAssoc()
getAll()
autoCommit()
commit()
rollback()
numRows()
affectedRows()
errorNative()
nextId()
createSequence()
dropSequence()
tableInfo()
getTables()
getListOf()
getSequenceName()
array_change_key_case()
toString() X-Ref |
String conversation return: string |
DB_common() X-Ref |
Constructor |
quoteString($string) X-Ref |
Quotes a string so it can be safely used within string delimiters in a query (preserved for compatibility issues, quote() is preffered). return: string quoted string |
quote($string) X-Ref |
Quotes a string so it can be safely used in a query. It will return the string with single quotes around. Other backend quote styles should override this method. param: string $string the input string to quote return: string The NULL string or the string quotes |
provides($feature) X-Ref |
Tell whether a DB implementation or its backend extension supports a given feature. param: array $feature name of the feature (see the DB class doc) return: bool whether this DB implementation supports $feature |
errorCode($nativecode) X-Ref |
Map native error codes to DB's portable ones. Requires that the DB implementation's constructor fills in the $errorcode_map property. param: mixed $nativecode the native error code, as returned by the backend return: int a portable DB error code, or FALSE if this DB |
errorMessage($dbcode) X-Ref |
Map a DB error code to a textual message. This is actually just a wrapper for DB::errorMessage(). param: integer $dbcode the DB error code return: string the corresponding error message, of FALSE |
raiseError($code = DB_ERROR, $mode = null, $options = null,$userinfo = null, $nativecode = null) X-Ref |
This method is used to communicate an error and invoke error callbacks etc. Basically a wrapper for PEAR::raiseError without the message string. param: mixed integer error code, or a PEAR error object (all param: int error mode, see PEAR_Error docs param: mixed If error mode is PEAR_ERROR_TRIGGER, this is the param: string Extra debug information. Defaults to the last param: mixed Native error code, integer or string depending the return: object a PEAR error object |
setFetchMode($fetchmode, $object_class = null) X-Ref |
Sets which fetch mode should be used by default on queries on this connection. param: integer $fetchmode DB_FETCHMODE_ORDERED or param: string $object_class The class of the object |
setOption($option, $value) X-Ref |
set the option for the db class param: string $option option name param: mixed $value value for the option return: mixed DB_OK or DB_Error |
getOption($option) X-Ref |
returns the value of an option param: string $option option name return: mixed the option value |
prepare($query) X-Ref |
Prepares a query for multiple execution with execute(). With some database backends, this is emulated. prepare() requires a generic query as string like "INSERT INTO numbers VALUES(?,?,?)". The ? are wildcards. Types of wildcards: ? - a quoted scalar value, i.e. strings, integers & - requires a file name, the content of the file insert into the query (i.e. saving binary data in a db) ! - value is inserted 'as is' param: string the query to prepare return: resource handle for the query |
autoPrepare($table, $table_fields, $mode = DB_AUTOQUERY_INSERT, $where = false) X-Ref |
Make automaticaly an insert or update query and call prepare() with it param: string $table name of the table param: array $table_fields ordered array containing the fields names param: int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE) param: string $where in case of update queries, this string will be put after the sql WHERE statement return: resource handle for the query |
autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT, $where = false) X-Ref |
Make automaticaly an insert or update query and call prepare() and execute() with it param: string $table name of the table param: array $fields_values assoc ($key=>$value) where $key is a field name and $value its value param: int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE) param: string $where in case of update queries, this string will be put after the sql WHERE statement return: mixed a new DB_Result or a DB_Error when fail |
buildManipSQL($table, $table_fields, $mode, $where = false) X-Ref |
Make automaticaly an sql query for prepare() Example : buildManipSQL('table_sql', array('field1', 'field2', 'field3'), DB_AUTOQUERY_INSERT) will return the string : INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?) NB : - This belongs more to a SQL Builder class, but this is a simple facility - Be carefull ! If you don't give a $where param with an UPDATE query, all the records of the table will be updated ! param: string $table name of the table param: array $table_fields ordered array containing the fields names param: int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE) param: string $where in case of update queries, this string will be put after the sql WHERE statement return: string sql query for prepare() |
execute($stmt, $data = false) X-Ref |
Executes a prepared SQL query With execute() the generic query of prepare is assigned with the given data array. The values of the array inserted into the query in the same order like the array order param: resource $stmt query handle from prepare() param: array $data numeric array containing the return: mixed a new DB_Result or a DB_Error when fail |
executeEmulateQuery($stmt, $data = false) X-Ref |
Emulates the execute statement, when not supported param: resource $stmt query handle from prepare() param: array $data numeric array containing the return: mixed a string containing the real query run when emulating |
executeMultiple( $stmt, &$data ) X-Ref |
This function does several execute() calls on the same statement handle. $data must be an array indexed numerically from 0, one execute call is done for every "row" in the array. If an error occurs during execute(), executeMultiple() does not execute the unfinished rows, but rather returns that error. param: resource $stmt query handle from prepare() param: array $data numeric array containing the return: mixed DB_OK or DB_Error |
freePrepared($stmt) X-Ref |
Pas de description |
modifyQuery($query) X-Ref |
This method is used by backends to alter queries for various reasons. It is defined here to assure that all implementations have this method defined. param: string $query query to modify return: the new (modified) query |
modifyLimitQuery($query, $from, $count) X-Ref |
This method is used by backends to alter limited queries param: string $query query to modify param: integer $from the row to start to fetching param: integer $count the numbers of rows to fetch return: the new (modified) query |
query($query, $params = array() X-Ref |
Send a query to the database and return any results with a DB_result object. param: string $query the SQL query or the statement to prepare param: string $params the data to be added to the query return: mixed a DB_result object or DB_OK on success, a DB |
limitQuery($query, $from, $count, $params = array() X-Ref |
Generates a limited query param: string $query query param: integer $from the row to start to fetching param: integer $count the numbers of rows to fetch param: array $params required for a statement return: mixed a DB_Result object, DB_OK or a DB_Error |
getOne($query, $params = array() X-Ref |
Fetch the first column of the first row of data returned from a query. Takes care of doing the query and freeing the results when finished. param: string $query the SQL query param: array $params if supplied, prepare/execute will be used return: mixed DB_Error or the returned value of the query |
getRow($query,$params = null,$fetchmode = DB_FETCHMODE_DEFAULT) X-Ref |
Fetch the first row of data returned from a query. Takes care of doing the query and freeing the results when finished. param: string $query the SQL query param: integer $fetchmode the fetch mode to use param: array $params array if supplied, prepare/execute will be used return: array the first row of results as an array indexed from |
getCol($query, $col = 0, $params = array() X-Ref |
Fetch a single column from a result set and return it as an indexed array. param: string $query the SQL query param: mixed $col which column to return (integer [column number, param: array $params array if supplied, prepare/execute will be used return: array an indexed array with the data from the first |
getAssoc($query, $force_array = false, $params = array() X-Ref |
Fetch the entire result set of a query and return it as an associative array using the first column as the key. If the result set contains more than two columns, the value will be an array of the values from column 2-n. If the result set contains only two columns, the returned value will be a scalar with the value of the second column (unless forced to an array with the $force_array parameter). A DB error code is returned on errors. If the result set contains fewer than two columns, a DB_ERROR_TRUNCATED error is returned. For example, if the table "mytable" contains: ID TEXT DATE -------------------------------- 1 'one' 944679408 2 'two' 944679408 3 'three' 944679408 Then the call getAssoc('SELECT id,text FROM mytable') returns: array( '1' => 'one', '2' => 'two', '3' => 'three', ) ...while the call getAssoc('SELECT id,text,date FROM mytable') returns: array( '1' => array('one', '944679408'), '2' => array('two', '944679408'), '3' => array('three', '944679408') ) If the more than one row occurs with the same value in the first column, the last row overwrites all previous ones by default. Use the $group parameter if you don't want to overwrite like this. Example: getAssoc('SELECT category,id,name FROM mytable', false, null, DB_FETCHMODE_ASSOC, true) returns: array( '1' => array(array('id' => '4', 'name' => 'number four'), array('id' => '6', 'name' => 'number six') ), '9' => array(array('id' => '4', 'name' => 'number four'), array('id' => '6', 'name' => 'number six') ) ) Keep in mind that database functions in PHP usually return string values for results regardless of the database's internal type. param: string $query the SQL query param: boolean $force_array used only when the query returns param: array $params array if supplied, prepare/execute will be used param: boolean $group if true, the values of the returned array return: array associative array with results from the query. |
getAll($query,$params = null,$fetchmode = DB_FETCHMODE_DEFAULT) X-Ref |
Fetch all the rows returned from a query. param: string $query the SQL query param: array $params array if supplied, prepare/execute will be used param: integer $fetchmode the fetch mode to use return: array an nested array, or a DB error |
autoCommit($onoff=false) X-Ref |
enable automatic Commit param: boolean $onoff return: mixed DB_Error |
commit() X-Ref |
starts a Commit return: mixed DB_Error |
rollback() X-Ref |
starts a rollback return: mixed DB_Error |
numRows($result) X-Ref |
returns the number of rows in a result object param: object DB_Result the result object to check return: mixed DB_Error or the number of rows |
affectedRows() X-Ref |
returns the affected rows of a query return: mixed DB_Error or number of rows |
errorNative() X-Ref |
returns an errormessage, provides by the database return: mixed DB_Error or message |
nextId($seq_name, $ondemand = true) X-Ref |
returns the next free id of a sequence param: string $seq_name name of the sequence param: boolean $ondemand when true the seqence is return: mixed DB_Error or id |
createSequence($seq_name) X-Ref |
creates a new sequence param: string $seq_name name of the new sequence return: mixed DB_Error |
dropSequence($seq_name) X-Ref |
deletes a sequence param: string $seq_name name of the sequence return: mixed DB_Error |
tableInfo($result, $mode = null) X-Ref |
returns meta data about the result set param: object DB_Result $result the result object to analyse param: mixed $mode depends on implementation return: mixed DB_Error |
getTables() X-Ref |
getListOf($type) X-Ref |
list internal DB info valid values for $type are db dependent, often: databases, users, view, functions param: string $type type of requested info return: mixed DB_Error or the requested data |
getSequenceName($sqn) X-Ref |
Pas de description |
array_change_key_case(&$array, $case) X-Ref |
Pas de description |
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |