DB_common is the base class from which each database driver class extends
All common methods are declared here. If a given DBMS driver contains a particular method, that method will overload the one here.
Located in /web/lib/external/pear-db/DB/common.php (line 48)
PEAR | --DB_common
Class | Description |
---|---|
![]() |
The methods PEAR DB uses to interact with PHP's ifx extension for interacting with Informix databases |
![]() |
The methods PEAR DB uses to interact with PHP's fbsql extension for interacting with FrontBase databases |
![]() |
The methods PEAR DB uses to interact with PHP's mssql extension for interacting with Microsoft SQL Server databases |
![]() |
The methods PEAR DB uses to interact with PHP's msql extension for interacting with Mini SQL databases |
![]() |
The methods PEAR DB uses to interact with PHP's mysqli extension for interacting with MySQL databases |
![]() |
The methods PEAR DB uses to interact with PHP's mysql extension for interacting with MySQL databases |
![]() |
The methods PEAR DB uses to interact with PHP's pgsql extension for interacting with PostgreSQL databases |
![]() |
The methods PEAR DB uses to interact with PHP's dbase extension for interacting with dBase databases |
![]() |
The methods PEAR DB uses to interact with PHP's oci8 extension for interacting with Oracle databases |
![]() |
The methods PEAR DB uses to interact with PHP's sqlite extension for interacting with SQLite databases |
![]() |
The methods PEAR DB uses to interact with PHP's odbc extension for interacting with databases via ODBC connections |
![]() |
The methods PEAR DB uses to interact with PHP's sybase extension for interacting with Sybase databases |
![]() |
The methods PEAR DB uses to interact with PHP's interbase extension for interacting with Interbase and Firebird databases |
The current default fetch mode
The name of the class into which results should be fetched when DB_FETCHMODE_OBJECT is in effect
The parameters from the most recently executed query
The most recently executed query
Run-time configuration options
The 'optimize' option has been deprecated. Use the 'portability' option instead.
The prepared queries
The elements from each prepared statement
The data types of the various elements in each prepared statement
Was a connection present when the object was serialized()?
Flag indicating that the last query was a manipulation query.
Flag indicating that the next query <em>must</em> be a manipulation query.
Determines the number of rows affected by a data maniuplation query
Enables or disables automatic commits
Automaticaly generates an insert or update query and call prepare() and execute() with it
Automaticaly generates an insert or update query and pass it to prepare()
Produces an SQL query string for autoPrepare()
Example:
buildManipSQL('table_sql', array('field1', 'field2', 'field3'), DB_AUTOQUERY_INSERT);
That returns INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?)
NOTES:
Commits the current transaction
Creates a new sequence
The name of a given sequence is determined by passing the string provided in the $seq_name argument through PHP's sprintf() function using the value from the seqname_format option as the sprintf()'s format argument.
seqname_format is set via setOption().
Deletes a sequence
Maps native error codes to DB's portable ones
Uses the $errorcode_map property defined in each driver.
Maps a DB error code to a textual message
Gets the DBMS' native error code produced by the last query
Escapes a string according to the current DBMS's standards
In SQLite, this makes things safe for inserts/updates, but may cause problems when performing text comparisons against columns containing binary data. See the PHP manual for more info.
Executes a DB statement prepared with prepare()
Example 1.
Emulates executing prepared statements if the DBMS not support them
Performs 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.
Frees the internal resources associated with a prepared query
Fetches all of the rows from a query result
Fetches an entire query result and returns 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.
Fetches a single column from a query result and returns it as an indexed array
Lists internal database information
Fetches the first column of the first row from a query result
Takes care of doing the query and freeing the results when finished.
Returns the value of an option
Fetches the first row of data returned from a query result
Takes care of doing the query and freeing the results when finished.
Generates the name used inside the database for a sequence
The createSequence() docblock contains notes about storing sequence names.
Obtains the query string needed for listing a given type of objects
Generates and executes a LIMIT query
Adds LIMIT clauses to a query string according to current DBMS standards
It is defined here to assure that all implementations have this method defined.
Changes a query string for various DBMS specific reasons
It is defined here to ensure all drivers have this method available.
Returns the next free id in a sequence
Sets (or unsets) a flag indicating that the next query will be a manipulation query, regardless of the usual DB::isManip() heuristics.
Determines the number of rows in a query result
Prepares a query for multiple execution with execute()
Creates a query that can be run multiple times. Each time it is run, the placeholders, if any, will be replaced by the contents of execute()'s $data argument.
Three types of placeholders can be used:
Use backslashes to escape placeholder characters if you don't want them to be interpreted as placeholders:
"UPDATE foo SET col=? WHERE col='over \& under'"
With some database backends, this is emulated.
Tells whether the present driver supports a given feature
Sends a query to the database server
The query string can be either a normal statement to be sent directly to the server OR if $params are passed the query can have placeholders and it will be passed through prepare() and execute().
DEPRECATED: Quotes a string so it can be safely used in a query
Formats a boolean value for use within a query in a locale-independent manner.
Formats a float value for use within a query in a locale-independent manner.
Quotes a string so it can be safely used as a table or column name
Delimiting style depends on which database driver is being used.
NOTE: just because you CAN use delimited identifiers doesn't mean you SHOULD use them. In general, they end up causing way more problems than they solve.
Portability is broken by using the following characters inside delimited identifiers:
Formats input so it can be safely used in a query
The output depends on the PHP data type of input and the database type being used.
DEPRECATED: Quotes a string so it can be safely used within string delimiters in a query
Communicates an error and invoke error callbacks, etc
Basically a wrapper for PEAR::raiseError without the message string.
Reverts the current transaction
Sets the fetch mode that should be used by default for query results
Sets run-time configuration options for PEAR DB
Options, their data types, default values and description:
-----------------------------------------
PORTABILITY MODES
These modes are bitwised, so they can be combined using | and removed using ^. See the examples section below on how to do this.
DB_PORTABILITY_NONE turn off all portability features
This mode gets automatically turned on if the deprecated optimize option gets set to performance.
DB_PORTABILITY_LOWERCASE convert names of tables and fields to lower case when using get*(), fetch*() and tableInfo()
This mode gets automatically turned on in the following databases if the deprecated option optimize gets set to portability:
DB_PORTABILITY_RTRIM right trim the data output by get*() fetch*()
DB_PORTABILITY_DELETE_COUNT force reporting the number of rows deleted
Some DBMS's don't count the number of rows deleted when performing simple DELETE FROM tablename queries. This portability mode tricks such DBMS's into telling the count by adding WHERE 1=1 to the end of DELETE queries.
This mode gets automatically turned on in the following databases if the deprecated option optimize gets set to portability:
DB_PORTABILITY_NUMROWS enable hack that makes numRows() work in Oracle
This mode gets automatically turned on in the following databases if the deprecated option optimize gets set to portability:
DB_PORTABILITY_ERRORS makes certain error messages in certain drivers compatible with those from other DBMS's
DB_PORTABILITY_ALL turn on all portability features
-----------------------------------------
Example 1. Simple setOption() example
Example 2. Portability for lowercasing and trimming
Example 3. All portability options except trimming
Returns information about a table or a result set
The format of the resulting array depends on which $mode you select. The sample output below is based on this query:
SELECT tblFoo.fldID, tblFoo.fldPhone, tblBar.fldId FROM tblFoo JOIN tblBar ON tblFoo.fldId = tblBar.fldId
[0] => Array ( [table] => tblFoo [name] => fldId [type] => int [len] => 11 [flags] => primary_key not_null ) [1] => Array ( [table] => tblFoo [name] => fldPhone [type] => string [len] => 20 [flags] => ) [2] => Array ( [table] => tblBar [name] => fldId [type] => int [len] => 11 [flags] => primary_key not_null )
[num_fields] => 3 [order] => Array ( [fldId] => 2 [fldTrans] => 1 )
[num_fields] => 3 [ordertable] => Array ( [tblFoo] => Array ( [fldId] => 0 [fldPhone] => 1 ) [tblBar] => Array ( [fldId] => 2 ) )
The flags element contains a space separated list of extra information about the field. This data is inconsistent between DBMS's due to the way each DBMS works.
Checks if the given query is a manipulation query. This also takes into account the _next_query_manip flag and sets the _last_query_manip flag (and resets _next_query_manip) according to the result.
Converts all null values in an array to empty strings
Right-trims all strings in an array
Automatically indicates which properties should be saved when PHP's serialize() function is called
Automatically reconnects to the database when PHP's unserialize() function is called
The reconnection attempt is only performed if the object was connected at the time PHP's serialize() function was run.
Inherited From PEAR
PEAR::PEAR()
PEAR::delExpect()
PEAR::expectError()
PEAR::getStaticProperty()
PEAR::isError()
PEAR::loadExtension()
PEAR::popErrorHandling()
PEAR::popExpect()
PEAR::pushErrorHandling()
PEAR::raiseError()
PEAR::registerShutdownFunc()
PEAR::setErrorHandling()
PEAR::staticPopErrorHandling()
PEAR::staticPushErrorHandling()
PEAR::throwError()
PEAR::_PEAR()
Documentation generated on Wed, 09 Feb 2011 08:59:06 +0700 by phpDocumentor 1.4.2