Difference between revisions of "JDatabase"
From Joomla! Documentation
(Layout updates) |
m (moving preparation) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
+ | =={{JVer|11.1}} JDatabase== | ||
+ | ===Description=== | ||
+ | {{Description:JDatabase}} | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[</nowiki>[[Description:JDatabase|Edit Descripton]]<nowiki>]</nowiki> | <nowiki>[</nowiki>[[Description:JDatabase|Edit Descripton]]<nowiki>]</nowiki> | ||
</span> | </span> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===Methods=== | ===Methods=== | ||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
|- | |- | ||
+ | !Visibility | ||
!Method name | !Method name | ||
!Description | !Description | ||
|- | |- | ||
− | |[[JDatabase:: | + | |public |
− | | | + | |[[API17:JDatabase::__call|__call]] |
+ | |Magic method to provide method alias support for and . | ||
|- | |- | ||
− | | | + | |public |
− | + | |[[API17:JDatabase::addQuoted|addQuoted]] | |
− | |||
− | |[[JDatabase::addQuoted | ||
|Adds a field or array of field names to the list that are to be quoted. | |Adds a field or array of field names to the list that are to be quoted. | ||
|- | |- | ||
− | |[[JDatabase::connected | + | |public |
+ | |[[API17:JDatabase::connected|connected]] | ||
|Determines if the connection to the server is active. | |Determines if the connection to the server is active. | ||
|- | |- | ||
− | |[[JDatabase::debug | + | |public |
+ | |[[API17:JDatabase::dateToString|dateToString]] | ||
+ | |Method to get a object represented as a datetime string in a format recognized by the database server. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::debug|debug]] | ||
|Sets the debug level on or off. | |Sets the debug level on or off. | ||
|- | |- | ||
− | |[[JDatabase::explain | + | |public |
− | |Diagnostic | + | |[[API17:JDatabase::explain|explain]] |
+ | |Diagnostic method to return explain information for a query. | ||
|- | |- | ||
− | |[[JDatabase::getAffectedRows | + | |public |
− | |Get the affected rows | + | |[[API17:JDatabase::getAffectedRows|getAffectedRows]] |
+ | |Get the number of affected rows for the previous executed SQL statement. | ||
|- | |- | ||
− | |[[JDatabase::getCollation | + | |public |
− | | | + | |[[API17:JDatabase::getCollation|getCollation]] |
+ | |Method to get the database collation in use by sampling a text field of a table in the database. | ||
|- | |- | ||
− | |[[JDatabase::getConnection | + | |public |
− | | | + | |[[API17:JDatabase::getConnection|getConnection]] |
+ | |Method that provides access to the underlying database connection. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |public |
− | |Get the database | + | |[[API17:JDatabase::getCount|getCount]] |
+ | |Get the total number of SQL statements executed by the database driver. | ||
|- | |- | ||
− | |[[JDatabase::getErrorMsg | + | |public |
− | | | + | |[[API17:JDatabase::getErrorMsg|getErrorMsg]] |
+ | |Gets the error message from the database connection. | ||
|- | |- | ||
− | |[[JDatabase::getErrorNum | + | |public |
− | | | + | |[[API17:JDatabase::getErrorNum|getErrorNum]] |
+ | |Gets the error number from the database connection. | ||
|- | |- | ||
− | |[[JDatabase::getEscaped | + | |public |
− | | | + | |[[API17:JDatabase::getEscaped|getEscaped]] |
+ | |Method to escape a string for usage in an SQL statement. | ||
|- | |- | ||
− | |[[JDatabase::getLog | + | |public |
− | |Get | + | |[[API17:JDatabase::getLog|getLog]] |
+ | |Get the database driver SQL statement log. | ||
|- | |- | ||
− | |[[JDatabase::getNullDate | + | |public |
− | |Get the database | + | |[[API17:JDatabase::getNullDate|getNullDate]] |
+ | |Get the null or zero representation of a timestamp for the database driver. | ||
|- | |- | ||
− | |[[JDatabase::getNumRows | + | |public |
− | |Get the number of rows | + | |[[API17:JDatabase::getNumRows|getNumRows]] |
+ | |Get the number of returned rows for the previous executed SQL statement. | ||
|- | |- | ||
− | |[[JDatabase::getPrefix | + | |public |
− | |Get the | + | |[[API17:JDatabase::getPrefix|getPrefix]] |
+ | |Get the common table prefix for the database driver. | ||
|- | |- | ||
− | |[[JDatabase::getQuery | + | |public |
+ | |[[API17:JDatabase::getQuery|getQuery]] | ||
|Get the current or query, or new object. | |Get the current or query, or new object. | ||
|- | |- | ||
− | |[[JDatabase::getTableCreate | + | |public |
− | |Shows the CREATE | + | |[[API17:JDatabase::getTableCreate|getTableCreate]] |
+ | |Shows the table CREATE statement that creates the given tables. | ||
|- | |- | ||
− | |[[JDatabase::getTableFields | + | |public |
− | |Retrieves information about the given tables. | + | |[[API17:JDatabase::getTableFields|getTableFields]] |
+ | |Retrieves field information about the given tables. | ||
|- | |- | ||
− | |[[JDatabase::getTableList | + | |public |
− | | | + | |[[API17:JDatabase::getTableList|getTableList]] |
+ | |Method to get an array of all tables in the database. | ||
|- | |- | ||
− | |[[JDatabase::getTicker | + | |public |
− | |Get the total number of | + | |[[API17:JDatabase::getTicker|getTicker]] |
+ | |Get the total number of SQL statements executed by the database driver. | ||
|- | |- | ||
− | |[[JDatabase::getUTFSupport | + | |public |
− | | | + | |[[API17:JDatabase::getUTFSupport|getUTFSupport]] |
+ | |Determine whether or not the database engine supports UTF-8 character encoding. | ||
|- | |- | ||
− | |[[JDatabase::getVersion | + | |public |
+ | |[[API17:JDatabase::getVersion|getVersion]] | ||
|Get the version of the database connector. | |Get the version of the database connector. | ||
|- | |- | ||
− | |[[JDatabase::hasUTF | + | |public |
− | |Determines UTF | + | |[[API17:JDatabase::hasUTF|hasUTF]] |
+ | |Determines if the database engine supports UTF-8 character encoding. | ||
|- | |- | ||
− | |[[JDatabase::insertid | + | |public |
− | | | + | |[[API17:JDatabase::insertid|insertid]] |
+ | |Method to get the auto-incremented value from the last INSERT statement. | ||
|- | |- | ||
− | |[[JDatabase::insertObject | + | |public |
− | |Inserts a row into a table based on an | + | |[[API17:JDatabase::insertObject|insertObject]] |
+ | |Inserts a row into a table based on an object's properties. | ||
|- | |- | ||
− | |[[JDatabase::isQuoted | + | |public |
+ | |[[API17:JDatabase::isQuoted|isQuoted]] | ||
|Checks if field name needs to be quoted. | |Checks if field name needs to be quoted. | ||
|- | |- | ||
− | |[[JDatabase::loadAssoc | + | |public |
− | | | + | |[[API17:JDatabase::loadAssoc|loadAssoc]] |
+ | |Method to get the first row of the result set from the database query as an associative array of ['field_name' => 'row_value']. | ||
|- | |- | ||
− | |[[JDatabase::loadAssocList | + | |public |
− | | | + | |[[API17:JDatabase::loadAssocList|loadAssocList]] |
+ | |Method to get an array of the result set rows from the database query where each row is an associative array of ['field_name' => 'row_value']. | ||
|- | |- | ||
− | |[[JDatabase::loadNextObject | + | |public |
− | | | + | |[[API17:JDatabase::loadNextObject|loadNextObject]] |
+ | |Method to get the next row in the result set from the database query as an object. | ||
|- | |- | ||
− | |[[JDatabase::loadNextRow | + | |public |
− | | | + | |[[API17:JDatabase::loadNextRow|loadNextRow]] |
+ | |Method to get the next row in the result set from the database query as an array. | ||
|- | |- | ||
− | |[[JDatabase::loadObject | + | |public |
− | | | + | |[[API17:JDatabase::loadObject|loadObject]] |
+ | |Method to get the first row of the result set from the database query as an object. | ||
|- | |- | ||
− | |[[JDatabase::loadObjectList | + | |public |
− | | | + | |[[API17:JDatabase::loadObjectList|loadObjectList]] |
+ | |Method to get an array of the result set rows from the database query where each row is an object. | ||
|- | |- | ||
− | |[[JDatabase::loadResult | + | |public |
− | | | + | |[[API17:JDatabase::loadResult|loadResult]] |
+ | |Method to get the first field of the first row of the result set from the database query. | ||
|- | |- | ||
− | |[[JDatabase::loadResultArray | + | |public |
− | | | + | |[[API17:JDatabase::loadResultArray|loadResultArray]] |
+ | |Method to get an array of values from the field in each row of the result set from the database query. | ||
|- | |- | ||
− | |[[JDatabase::loadRow | + | |public |
− | | | + | |[[API17:JDatabase::loadRow|loadRow]] |
+ | |Method to get the first row of the result set from the database query as an array. | ||
|- | |- | ||
− | |[[JDatabase::loadRowList | + | |public |
− | | | + | |[[API17:JDatabase::loadRowList|loadRowList]] |
+ | |Method to get an array of the result set rows from the database query where each row is an array. | ||
|- | |- | ||
− | |[[JDatabase::nameQuote | + | |public |
− | | | + | |[[API17:JDatabase::nameQuote|nameQuote]] |
+ | |Wrap an SQL statement identifier name such as field, table or database names in quotes to prevent injection risks and reserved word conflicts. | ||
|- | |- | ||
− | |[[JDatabase::query | + | |public |
− | |Execute the | + | |[[API17:JDatabase::query|query]] |
+ | |Execute the SQL statement. | ||
|- | |- | ||
− | |[[JDatabase::queryBatch | + | |public |
− | |Execute a batch | + | |[[API17:JDatabase::queryBatch|queryBatch]] |
+ | |Execute a query batch. | ||
|- | |- | ||
− | |[[JDatabase::quote | + | |public |
− | | | + | |[[API17:JDatabase::quote|quote]] |
+ | |Method to quote and optionally escape a string to database requirements for insertion into the database. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |public |
− | | | + | |[[API17:JDatabase::select|select]] |
+ | |Select a database for use. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::setDebug|setDebug]] | ||
+ | |Sets the database debugging state for the driver. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::setQuery|setQuery]] | ||
+ | |Sets the SQL statement string for later execution. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::setUTF|setUTF]] | ||
+ | |Set the connection to use UTF-8 character encoding. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::stderr|stderr]] | ||
+ | |Return the most recent error message for the database connector. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::transactionCommit|transactionCommit]] | ||
+ | |Method to commit a transaction. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::transactionRollback|transactionRollback]] | ||
+ | |Method to roll back a transaction. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::transactionStart|transactionStart]] | ||
+ | |Method to initialize a transaction. | ||
+ | |- | ||
+ | |public | ||
+ | |[[API17:JDatabase::updateObject|updateObject]] | ||
+ | |Updates a row in a table based on an object's properties. | ||
+ | |- | ||
+ | |public static | ||
+ | |[[API17:JDatabase::getConnectors|getConnectors]] | ||
+ | |Get a list of available database connectors. | ||
+ | |- | ||
+ | |public static | ||
+ | |[[API17:JDatabase::getInstance|getInstance]] | ||
+ | |Method to return a instance based on the given options. | ||
+ | |- | ||
+ | |public static | ||
+ | |[[API17:JDatabase::splitSql|splitSql]] | ||
+ | |Splits a string of multiple queries into an array of individual queries. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |public static |
− | | | + | |[[API17:JDatabase::test|test]] |
+ | |Test to see if the connector is available. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |protected |
− | | | + | |[[API17:JDatabase::__construct|__construct]] |
+ | |Constructor. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |protected |
− | | | + | |[[API17:JDatabase::fetchArray|fetchArray]] |
+ | |Method to fetch a row from the result set cursor as an array. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |protected |
− | | | + | |[[API17:JDatabase::fetchAssoc|fetchAssoc]] |
+ | |Method to fetch a row from the result set cursor as an associative array. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |protected |
− | | | + | |[[API17:JDatabase::fetchObject|fetchObject]] |
+ | |Method to fetch a row from the result set cursor as an object. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |protected |
− | | | + | |[[API17:JDatabase::freeResult|freeResult]] |
+ | |Method to free up the memory used for the result set. | ||
|- | |- | ||
− | |[[JDatabase:: | + | |protected |
− | | | + | |[[API17:JDatabase::replacePrefix|replacePrefix]] |
+ | |This function replaces a string identifier with the string held is the class variable. | ||
|- | |- | ||
|} | |} | ||
+ | * '''Defined in''' libraries/joomla/database/database.php | ||
+ | * '''Extended by''' | ||
+ | ** [[API17:JDatabaseMySQL|JDatabaseMySQL]] | ||
+ | ** [[API17:JDatabaseMySQLi|JDatabaseMySQLi]] | ||
+ | ** [[API17:JDatabaseSQLAzure|JDatabaseSQLAzure]] | ||
+ | ** [[API17:JDatabaseSQLSrv|JDatabaseSQLSrv]] | ||
===Importing=== | ===Importing=== | ||
<source lang="php">jimport( 'joomla.database.database' );</source> | <source lang="php">jimport( 'joomla.database.database' );</source> | ||
===See also=== | ===See also=== | ||
− | * JDatabase source code | + | * {{JVer|11.1}} '''JDatabase source code''' on [[jplatform:database/database.php|BitBucket]] |
− | * [[JDatabase|Other versions of | + | * {{JVer|11.1}} Subpackage [[API17:Subpackage Database|Database]] |
+ | * [[API17:JDatabase|Other versions of JDatabase]] | ||
{{SeeAlso:JDatabase}} | {{SeeAlso:JDatabase}} | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[</nowiki>[[SeeAlso:JDatabase|Edit See Also]]<nowiki>]</nowiki> | <nowiki>[</nowiki>[[SeeAlso:JDatabase|Edit See Also]]<nowiki>]</nowiki> | ||
</span> | </span> | ||
− | === | + | ===User contributed notes=== |
<CodeExamplesForm /> | <CodeExamplesForm /> | ||
<dpl> | <dpl> | ||
Line 188: | Line 282: | ||
category=ClassExample | category=ClassExample | ||
include=* | include=* | ||
+ | namespace=CodeExample | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
− | <noinclude> | + | <noinclude>[[Category:Platform 11.1]][[Category:Archived pages API17]]</noinclude> |
Revision as of 20:00, 11 May 2013
The "API17" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
JDatabase[edit]
Description[edit]
Template:Description:JDatabase [Edit Descripton]
Methods[edit]
Visibility | Method name | Description |
---|---|---|
public | __call | Magic method to provide method alias support for and . |
public | addQuoted | Adds a field or array of field names to the list that are to be quoted. |
public | connected | Determines if the connection to the server is active. |
public | dateToString | Method to get a object represented as a datetime string in a format recognized by the database server. |
public | debug | Sets the debug level on or off. |
public | explain | Diagnostic method to return explain information for a query. |
public | getAffectedRows | Get the number of affected rows for the previous executed SQL statement. |
public | getCollation | Method to get the database collation in use by sampling a text field of a table in the database. |
public | getConnection | Method that provides access to the underlying database connection. |
public | getCount | Get the total number of SQL statements executed by the database driver. |
public | getErrorMsg | Gets the error message from the database connection. |
public | getErrorNum | Gets the error number from the database connection. |
public | getEscaped | Method to escape a string for usage in an SQL statement. |
public | getLog | Get the database driver SQL statement log. |
public | getNullDate | Get the null or zero representation of a timestamp for the database driver. |
public | getNumRows | Get the number of returned rows for the previous executed SQL statement. |
public | getPrefix | Get the common table prefix for the database driver. |
public | getQuery | Get the current or query, or new object. |
public | getTableCreate | Shows the table CREATE statement that creates the given tables. |
public | getTableFields | Retrieves field information about the given tables. |
public | getTableList | Method to get an array of all tables in the database. |
public | getTicker | Get the total number of SQL statements executed by the database driver. |
public | getUTFSupport | Determine whether or not the database engine supports UTF-8 character encoding. |
public | getVersion | Get the version of the database connector. |
public | hasUTF | Determines if the database engine supports UTF-8 character encoding. |
public | insertid | Method to get the auto-incremented value from the last INSERT statement. |
public | insertObject | Inserts a row into a table based on an object's properties. |
public | isQuoted | Checks if field name needs to be quoted. |
public | loadAssoc | Method to get the first row of the result set from the database query as an associative array of ['field_name' => 'row_value']. |
public | loadAssocList | Method to get an array of the result set rows from the database query where each row is an associative array of ['field_name' => 'row_value']. |
public | loadNextObject | Method to get the next row in the result set from the database query as an object. |
public | loadNextRow | Method to get the next row in the result set from the database query as an array. |
public | loadObject | Method to get the first row of the result set from the database query as an object. |
public | loadObjectList | Method to get an array of the result set rows from the database query where each row is an object. |
public | loadResult | Method to get the first field of the first row of the result set from the database query. |
public | loadResultArray | Method to get an array of values from the field in each row of the result set from the database query. |
public | loadRow | Method to get the first row of the result set from the database query as an array. |
public | loadRowList | Method to get an array of the result set rows from the database query where each row is an array. |
public | nameQuote | Wrap an SQL statement identifier name such as field, table or database names in quotes to prevent injection risks and reserved word conflicts. |
public | query | Execute the SQL statement. |
public | queryBatch | Execute a query batch. |
public | quote | Method to quote and optionally escape a string to database requirements for insertion into the database. |
public | select | Select a database for use. |
public | setDebug | Sets the database debugging state for the driver. |
public | setQuery | Sets the SQL statement string for later execution. |
public | setUTF | Set the connection to use UTF-8 character encoding. |
public | stderr | Return the most recent error message for the database connector. |
public | transactionCommit | Method to commit a transaction. |
public | transactionRollback | Method to roll back a transaction. |
public | transactionStart | Method to initialize a transaction. |
public | updateObject | Updates a row in a table based on an object's properties. |
public static | getConnectors | Get a list of available database connectors. |
public static | getInstance | Method to return a instance based on the given options. |
public static | splitSql | Splits a string of multiple queries into an array of individual queries. |
public static | test | Test to see if the connector is available. |
protected | __construct | Constructor. |
protected | fetchArray | Method to fetch a row from the result set cursor as an array. |
protected | fetchAssoc | Method to fetch a row from the result set cursor as an associative array. |
protected | fetchObject | Method to fetch a row from the result set cursor as an object. |
protected | freeResult | Method to free up the memory used for the result set. |
protected | replacePrefix | This function replaces a string identifier with the string held is the class variable. |
- Defined in libraries/joomla/database/database.php
- Extended by
Importing[edit]
jimport( 'joomla.database.database' );
See also[edit]
- JDatabase source code on BitBucket
- Subpackage Database
- Other versions of JDatabase
Template:SeeAlso:JDatabase [Edit See Also]
User contributed notes[edit]
<CodeExamplesForm />