Joomla CMS
3.10.11 (avec JPlatform 13.1 inclus)
Documentation des API du CMS Joomla en version 3.10.11 et du framework Joomla Platform intégré
|
Fonctions membres publiques statiques | |
static | getConnectors () |
static | getInstance ($options=array()) |
static | splitSql ($sql) |
Fonctions membres publiques statiques hérités de JDatabase | |
static | getConnectors () |
static | getInstance ($options=array()) |
static | splitSql ($query) |
static | test () |
Fonctions membres publiques statiques hérités de JDatabaseInterface | |
static | isSupported () |
Champs de données | |
$name | |
$serverType | |
Fonctions membres protégées | |
fetchArray ($cursor=null) | |
fetchAssoc ($cursor=null) | |
fetchObject ($cursor=null, $class='stdClass') | |
freeResult ($cursor=null) | |
getCreateDatabaseQuery ($options, $utf) | |
getDatabase () | |
quoteNameStr ($strArr) | |
Attributs protégés | |
$connection | |
$count = 0 | |
$cursor | |
$debug = false | |
$limit = 0 | |
$log = array() | |
$timings = array() | |
$callStacks = array() | |
$nameQuote | |
$nullDate | |
$offset = 0 | |
$options | |
$sql | |
$tablePrefix | |
$utf = true | |
$utf8mb4 = false | |
$errorNum = 0 | |
$errorMsg | |
$transactionDepth = 0 | |
$disconnectHandlers = array() | |
Attributs protégés statiques | |
static | $instances = array() |
static | $dbMinimum |
Attributs privés | |
$_database | |
Joomla Platform Database Driver Class
string|array q() q($text, $escape = true) Alias for quote method string|array qn() qn($name, $as = null) Alias for quoteName method
__construct | ( | $options | ) |
Constructor.
array | $options | List of options used to configure the connection |
Références $options.
__destruct | ( | ) |
Destructor.
__call | ( | $method, | |
$args | |||
) |
Magic method to provide method alias support for quote() and quoteName().
string | $method | The called method. |
array | $args | The array of arguments passed to the method. |
Références null.
addDisconnectHandler | ( | $callable | ) |
Adds a function callable just before disconnecting the database. Parameter of the callable is $this JDatabaseDriver
callable | $callable | Function to call in disconnect() method just before disconnecting from database |
alterDbCharacterSet | ( | $dbName | ) |
Alter database's character set, obtaining query string from protected member.
string | $dbName | The database name that will be altered |
RuntimeException |
alterTableCharacterSet | ( | $tableName, | |
$rethrow = false |
|||
) |
Alter a table's character set, obtaining an array of queries to do so from a protected method. The conversion is wrapped in a transaction, if supported by the database driver. Otherwise the table will be locked before the conversion. This prevents data corruption.
string | $tableName | The name of the table to alter |
boolean | $rethrow | True to rethrow database exceptions. Default: false (exceptions are suppressed) |
RuntimeException | If the table name is empty |
Exception | Relayed from the database layer if a database error occurs and $rethrow == true |
Références $query.
|
abstract |
Connects to the database if needed.
RuntimeException |
|
abstract |
Determines if the connection to the server is active.
convertUtf8mb4QueryToUtf8 | ( | $query | ) |
createDatabase | ( | $options, | |
$utf = true |
|||
) |
Create a new database using information from $options object, obtaining query string from protected member.
stdClass | $options | Object used to pass user and database name to database driver. This object must have "db_name" and "db_user" set. |
boolean | $utf | True if the database supports the UTF-8 character set. |
RuntimeException |
|
abstract |
Disconnects the database.
|
abstract |
Drops a table from the database.
string | $table | The name of the database table to drop. |
boolean | $ifExists | Optionally specify that the table must exist before it is dropped. |
RuntimeException |
|
abstract |
Escapes a string for usage in an SQL statement.
string | $text | The string to be escaped. |
boolean | $extra | Optional parameter to provide extra escaping. |
|
abstract |
Execute the SQL statement.
RuntimeException |
|
abstractprotected |
Method to fetch a row from the result set cursor as an array.
mixed | $cursor | The optional result set cursor from which to fetch the row. |
|
abstractprotected |
Method to fetch a row from the result set cursor as an associative array.
mixed | $cursor | The optional result set cursor from which to fetch the row. |
|
abstractprotected |
Method to fetch a row from the result set cursor as an object.
mixed | $cursor | The optional result set cursor from which to fetch the row. |
string | $class | The class name to use for the returned row object. |
|
abstractprotected |
Method to free up the memory used for the result set.
mixed | $cursor | The optional result set cursor from which to fetch the row. |
|
abstract |
Get the number of affected rows for the previous executed SQL statement.
getAlterDbCharacterSet | ( | $dbName | ) |
Return the query string to alter the database character set.
string | $dbName | The database name |
getAlterTableCharacterSet | ( | $tableName | ) |
Get the query strings to alter the character set and collation of a table.
string | $tableName | The name of the table |
We also need to convert each text column, modifying their character set and collation. This allows us to change, for example, a utf8_bin collated column to a utf8mb4_bin collated column.
If the collation is in the form charset_collationType_ci or charset_collationType we have to change the charset but leave the collationType intact (e.g. utf8_bin must become utf8mb4_bin, NOT utf8mb4_general_ci).
When the last part of the old collation is not _ci we have a charset_collationType format, something like utf8_bin. Therefore the new collation only has two parts.
getCallStacks | ( | ) |
Get the database driver SQL statement log.
|
abstract |
Method to get the database collation in use by sampling a text field of a table in the database.
getConnection | ( | ) |
Method that provides access to the underlying database connection. Useful for when you need to call a proprietary method such as postgresql's lo_* methods.
getConnectionCollation | ( | ) |
Method to get the database connection collation, as reported by the driver. If the connector doesn't support reporting this value please return an empty string.
|
static |
Get a list of available database connectors. The list will only be populated with connectors that both the class exists and the static test method returns true. This gives us the ability to have a multitude of connector classes that are self-aware as to whether or not they are able to be used on a given system.
Référencé par JDatabase\getConnectors(), JFormFieldDatabaseConnection\getOptions(), et InstallationModelSetup\getPhpOptions().
getCount | ( | ) |
Get the total number of SQL statements executed by the database driver.
Références $count.
|
protected |
Return the query string to create new Database. Each database driver, other than MySQL, need to override this member to return correct string.
stdClass | $options | Object used to pass user and database name to database driver. This object must have "db_name" and "db_user" set. |
boolean | $utf | True if the database supports the UTF-8 character set. |
Références $options.
|
protected |
Gets the name of the database used by this connection.
getDateFormat | ( | ) |
Returns a PHP date() function compliant date format for the database driver.
getExporter | ( | ) |
Gets an exporter class object.
RuntimeException |
getImporter | ( | ) |
Gets an importer class object.
RuntimeException |
|
static |
Method to return a JDatabaseDriver instance based on the given options. There are three global options and then the rest are specific to the database driver. The 'driver' option defines which JDatabaseDriver class is used for the connection – the default is 'mysqli'. The 'database' option determines which database is to be used for the connection. The 'select' option determines whether the connector should automatically select the chosen database.
Instances are unique to the given options and new objects are only created when a unique options array is passed into the method. This ensures that we don't end up with unnecessary database connection resources.
array | $options | Parameters to be passed to the database driver. |
RuntimeException |
Références $class, $options, JDatabaseDriverPdomysql\isSupported(), JDatabaseDriverMysqli\isSupported(), et null.
Référencé par DatabaseLogger\connect(), InstallationModelDatabase\createDatabase(), Factory\createDbo(), InstallationHelperDatabase\getDbo(), JDatabase\getInstance(), et ConfigModelApplication\save().
getIterator | ( | $column = null , |
|
$class = 'stdClass' |
|||
) |
Get a new iterator on the current query.
string | $column | An option column to use as the iterator key. |
string | $class | The class of object that is returned. |
RuntimeException |
getLog | ( | ) |
Get the database driver SQL statement log.
getMinimum | ( | ) |
Get the minimum supported database version.
getName | ( | ) |
Get the name of the database driver. If $this->name is not set it will try guessing the driver name from the class name.
Références $className, $name, et name.
getNullDate | ( | ) |
Get the null or zero representation of a timestamp for the database driver.
|
abstract |
Get the number of returned rows for the previous executed SQL statement.
resource | $cursor | An optional database cursor resource to extract the row count from. |
getPrefix | ( | ) |
Get the common table prefix for the database driver.
getQuery | ( | $new = false | ) |
Get the current query object or a new JDatabaseQuery object.
boolean | $new | False to return the current query object, True to return a new JDatabaseQuery object. |
RuntimeException |
getServerType | ( | ) |
Get the server family type, e.g. mysql, postgresql, oracle, sqlite, mssql. If $this->serverType is not set it will attempt guessing the server family type from the driver name. If this is not possible the driver name will be returned instead.
|
abstract |
Retrieves field information about the given tables.
string | $table | The name of the database table. |
boolean | $typeOnly | True (default) to only return field types. |
RuntimeException |
|
abstract |
Shows the table CREATE statement that creates the given tables.
mixed | $tables | A table name or a list of table names. |
RuntimeException |
|
abstract |
Retrieves keys information about the given table.
string | $table | The name of the table. |
RuntimeException |
|
abstract |
Method to get an array of all tables in the database.
RuntimeException |
getTimings | ( | ) |
Get the database driver SQL statement log.
getUTFSupport | ( | ) |
Determine whether or not the database engine supports UTF-8 character encoding.
|
abstract |
Get the version of the database connector
hasUTF8mb4Support | ( | ) |
Determine whether the database engine support the UTF-8 Multibyte (utf8mb4) character encoding. This applies to MySQL databases.
hasUTFSupport | ( | ) |
Determine whether or not the database engine supports UTF-8 character encoding.
|
abstract |
Method to get the auto-incremented value from the last INSERT statement.
insertObject | ( | $table, | |
& | $object, | ||
$key = null |
|||
) |
Inserts a row into a table based on an object's properties.
string | $table | The name of the database table to insert into. |
object | &$object | A reference to an object whose public properties match the table fields. |
string | $key | The name of the primary key. If provided the object property is updated. |
RuntimeException |
isMinimumVersion | ( | ) |
Method to check whether the installed database version is supported by the database driver
loadAssoc | ( | ) |
Method to get the first row of the result set from the database query as an associative array of ['field_name' => 'row_value'].
RuntimeException |
Références null.
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']. The array of rows can optionally be keyed by a field name, but defaults to a sequential numeric array.
NOTE: Choosing to key the result array by a non-unique field name can result in unwanted behavior and should be avoided.
string | $key | The name of a field on which to key the result array. |
string | $column | An optional column name. Instead of the whole row, only this column value will be in the result array. |
RuntimeException |
loadColumn | ( | $offset = 0 | ) |
Method to get an array of values from the $offset field in each row of the result set from the database query.
integer | $offset | The row offset to use to build the result array. |
RuntimeException |
loadNextObject | ( | $class = 'stdClass' | ) |
Method to get the next row in the result set from the database query as an object.
string | $class | The class name to use for the returned row object. |
RuntimeException |
loadNextRow | ( | ) |
Method to get the next row in the result set from the database query as an array.
RuntimeException |
loadObject | ( | $class = 'stdClass' | ) |
loadObjectList | ( | $key = '' , |
|
$class = 'stdClass' |
|||
) |
Method to get an array of the result set rows from the database query where each row is an object. The array of objects can optionally be keyed by a field name, but defaults to a sequential numeric array.
NOTE: Choosing to key the result array by a non-unique field name can result in unwanted behavior and should be avoided.
string | $key | The name of a field on which to key the result array. |
string | $class | The class name to use for the returned row objects. |
RuntimeException |
loadResult | ( | ) |
loadRow | ( | ) |
Method to get the first row of the result set from the database query as an array. Columns are indexed numerically so the first column in the result set would be accessible via $row[0], etc.
RuntimeException |
loadRowList | ( | $index = null | ) |
Method to get an array of the result set rows from the database query where each row is an array. The array of objects can optionally be keyed by a field offset, but defaults to a sequential numeric array.
NOTE: Choosing to key the result array by a non-unique field can result in unwanted behavior and should be avoided.
integer | $index | The index of a field on which to key the result array. |
RuntimeException |
|
abstract |
Locks a table in the database.
string | $tableName | The name of the table to unlock. |
RuntimeException |
quote | ( | $text, | |
$escape = true |
|||
) |
Quotes and optionally escapes a string to database requirements for use in database queries.
mixed | $text | A string or an array of strings to quote. |
boolean | $escape | True (default) to escape the string, false to leave it unchanged. |
Références $text.
quoteBinary | ( | $data | ) |
Quotes a binary string to database requirements for use in database queries.
mixed | $data | A binary string to quote. |
Références $data.
quoteName | ( | $name, | |
$as = null |
|||
) |
Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection risks and reserved word conflicts.
mixed | $name | The identifier name to wrap in quotes, or an array of identifier names to wrap in quotes. Each type supports dot-notation name. |
mixed | $as | The AS query part associated to $name. It can be string or array, in latter case it has to be same length of $name; if is null there will not be any AS part for string or array element. |
|
protected |
Quote strings coming from quoteName call.
array | $strArr | Array of strings coming from quoteName dot-explosion. |
Références $parts.
Renames a table in the database.
string | $oldTable | The name of the table to be renamed |
string | $newTable | The new name for the table. |
string | $backup | Table prefix |
string | $prefix | For the table - used to rename constraints in non-mysql databases |
RuntimeException |
replacePrefix | ( | $sql, | |
$prefix = '#__' |
|||
) |
|
abstract |
Select a database for use.
string | $database | The name of the database to select for use. |
RuntimeException |
setDebug | ( | $level | ) |
setQuery | ( | $query, | |
$offset = 0 , |
|||
$limit = 0 |
|||
) |
Sets the SQL statement string for later execution.
mixed | $query | The SQL statement to set either as a JDatabaseQuery object or a string. |
integer | $offset | The affected row offset to set. |
integer | $limit | The maximum affected rows to set. |
|
abstract |
Set the connection to use UTF-8 character encoding.
|
static |
Splits a string of multiple queries into an array of individual queries. Single line or line end comments and multi line comments are stripped off.
string | $sql | Input SQL string with which to split into individual queries. |
Références $current, $i, $query, $start, et elseif.
Référencé par ChangeSet\getUpdateQueries(), Installer\parseSchemaUpdates(), Installer\parseSQLFiles(), et JDatabase\splitSql().
|
abstract |
Method to commit a transaction.
boolean | $toSavepoint | If true, commit to the last savepoint. |
RuntimeException |
|
abstract |
Method to roll back a transaction.
boolean | $toSavepoint | If true, rollback to the last savepoint. |
RuntimeException |
|
abstract |
Method to initialize a transaction.
boolean | $asSavepoint | If true and a transaction is already active, a savepoint will be created. |
RuntimeException |
truncateTable | ( | $table | ) |
Method to truncate a table.
string | $table | The table to truncate |
RuntimeException |
|
abstract |
Unlocks tables in the database.
RuntimeException |
updateObject | ( | $table, | |
& | $object, | ||
$key, | |||
$nulls = false |
|||
) |
Updates a row in a table based on an object's properties.
string | $table | The name of the database table to update. |
object | &$object | A reference to an object whose public properties match the table fields. |
array | string | $key | The name of the primary key. |
boolean | $nulls | True to update null fields or false to ignore them. |
RuntimeException |
|
private |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
$name |
|
protected |
|
protected |
|
protected |
|
protected |
$serverType |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |