JDatabaseMysql
class JDatabaseMysql extends JDatabaseDriverMysql
MySQL database driver
Properties
string | $name | The name of the database driver. | from JDatabaseDriverMysql |
string | $serverType | The type of the database server family supported by this driver. | from JDatabaseDriverMysqli |
Methods
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.
Gets the error message from the database connection.
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.
Splits a string of multiple queries into an array of individual queries.
Return the most recent error message for the database connector.
Magic method to provide method alias support for quote() and quoteName().
Alter database's character set, obtaining query string from protected member.
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.
Create a new database using information from $options object, obtaining query string from protected member.
Adds a function callable just before disconnecting the database. Parameter of the callable is $this JDatabaseDriver
Drops a table from the database.
Method to escape a string for usage in an SQL statement.
Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE for the previous executed SQL statement.
Return the query string to alter the database character set.
Get the query strings to alter the character set and collation of a table.
Automatically downgrade a CREATE TABLE or ALTER TABLE query from utf8mb4 (UTF-8 Multibyte) to plain utf8. Used when the server doesn't support UTF-8 Multibyte.
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.
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.
Get the total number of SQL statements executed by the database driver.
Returns a PHP date() function compliant date format for the database driver.
Get the null or zero representation of a timestamp for the database driver.
Get the number of returned rows for the previous executed SQL statement.
Get the name of the database driver. If $this->name is not set it will try guessing the driver name from the class name.
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.
Get the current query object or a new JDatabaseQuery object.
Get a new iterator on the current query.
Retrieves field information about a given table.
Shows the table CREATE statement that creates the given tables.
Get the details list of keys for a table.
Method to get an array of all tables in the database.
Determine whether or not the database engine supports UTF-8 character encoding.
Determine whether or not the database engine supports UTF-8 character encoding.
Determine whether the database engine support the UTF-8 Multibyte (utf8mb4) character encoding. This applies to MySQL databases.
Method to get the auto-incremented value from the last INSERT statement.
Inserts a row into a table based on an object's properties.
Method to check whether the installed database version is supported by the database driver
Method to get the first row of the result set from the database query as an associative array of ['fieldname' => 'rowvalue'].
Method to get an array of the result set rows from the database query where each row is an associative array of ['fieldname' => 'rowvalue']. The array of rows can optionally be keyed by a field name, but defaults to a sequential numeric array.
Method to get an array of values from the $offset field in each row of the result set from the database query.
Method to get the next row in the result set from the database query as an object.
Method to get the next row in the result set from the database query as an array.
Method to get the first row of the result set from the database query as an object.
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.
Method to get the first field of the first row of the result set from the database query.
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.
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.
Quotes and optionally escapes a string to database requirements for use in database queries.
Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection risks and reserved word conflicts.
This function replaces a string identifier $prefix with the string held is the tablePrefix class variable.
Renames a table in the database.
Sets the database debugging state for the driver.
Sets the SQL statement string for later execution.
Method to commit a transaction.
Method to roll back a transaction.
Method to initialize a transaction.
Updates a row in a table based on an object's properties.
Test to see if the MySQL connector is available.
Details
static
array
getConnectors()
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.
static
JDatabaseDriver
getInstance(
array $options = array())
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.
static
array
splitSql(
string $sql)
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
stderr(
boolean $showSQL = false)
Return the most recent error message for the database connector.
mixed
__call(
string $method,
array $args)
Magic method to provide method alias support for quote() and quoteName().
string
alterDbCharacterSet(
string $dbName)
Alter database's character set, obtaining query string from protected member.
boolean
alterTableCharacterSet(
string $tableName,
boolean $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
createDatabase(
stdClass $options,
boolean $utf = true)
Create a new database using information from $options object, obtaining query string from protected member.
void
addDisconnectHandler(
callable $callable)
Adds a function callable just before disconnecting the database. Parameter of the callable is $this JDatabaseDriver
JDatabaseDriver
dropTable(
string $tableName,
boolean $ifExists = true)
Drops a table from the database.
string
escape(
string $text,
boolean $extra = false)
Method to escape a string for usage in an SQL statement.
integer
getAffectedRows()
Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE for the previous executed SQL statement.
string
getAlterDbCharacterSet(
string $dbName)
Return the query string to alter the database character set.
string[]
getAlterTableCharacterSet(
string $tableName)
Get the query strings to alter the character set and collation of a table.
string
convertUtf8mb4QueryToUtf8(
string $query)
Automatically downgrade a CREATE TABLE or ALTER TABLE query from utf8mb4 (UTF-8 Multibyte) to plain utf8. Used when the server doesn't support UTF-8 Multibyte.
string
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.
resource
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.
integer
getNumRows(
resource $cursor = null)
Get the number of returned rows for the previous executed SQL statement.
This command is only valid for statements like SELECT or SHOW that return an actual result set. To retrieve the number of rows affected by an INSERT, UPDATE, REPLACE or DELETE query, use getAffectedRows().
string
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.
string
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.
JDatabaseQuery
getQuery(
boolean $new = false)
Get the current query object or a new JDatabaseQuery object.
JDatabaseIterator
getIterator(
string $column = null,
string $class = 'stdClass')
Get a new iterator on the current query.
array
getTableColumns(
string $table,
boolean $typeOnly = true)
Retrieves field information about a given table.
array
getTableCreate(
mixed $tables)
Shows the table CREATE statement that creates the given tables.
boolean
getUTFSupport()
Determine whether or not the database engine supports UTF-8 character encoding.
boolean
hasUTFSupport()
Determine whether or not the database engine supports UTF-8 character encoding.
boolean
hasUTF8mb4Support()
Determine whether the database engine support the UTF-8 Multibyte (utf8mb4) character encoding. This applies to MySQL databases.
boolean
insertObject(
string $table,
object $object,
string $key = null)
Inserts a row into a table based on an object's properties.
boolean
isMinimumVersion()
Method to check whether the installed database version is supported by the database driver
mixed
loadAssoc()
Method to get the first row of the result set from the database query as an associative array of ['fieldname' => 'rowvalue'].
mixed
loadAssocList(
string $key = null,
string $column = null)
Method to get an array of the result set rows from the database query where each row is an associative array of ['fieldname' => 'rowvalue']. The array of rows can optionally be keyed by a field name, but defaults to a sequential numeric array.
NOTE: Chosing to key the result array by a non-unique field name can result in unwanted behavior and should be avoided.
mixed
loadColumn(
integer $offset)
Method to get an array of values from the $offset field in each row of the result set from the database query.
mixed
loadNextObject(
string $class = 'stdClass')
Method to get the next row in the result set from the database query as an object.
mixed
loadNextRow()
Method to get the next row in the result set from the database query as an array.
mixed
loadObject(
string $class = 'stdClass')
Method to get the first row of the result set from the database query as an object.
mixed
loadObjectList(
string $key = '',
string $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.
mixed
loadResult()
Method to get the first field of the first row of the result set from the database query.
mixed
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.
mixed
loadRowList(
integer $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.
string|array
quote(
mixed $text,
boolean $escape = true)
Quotes and optionally escapes a string to database requirements for use in database queries.
mixed
quoteName(
mixed $name,
mixed $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.
string
replacePrefix(
string $sql,
string $prefix = '#__')
This function replaces a string identifier $prefix with the string held is the tablePrefix class variable.
JDatabaseDriver
renameTable(
string $oldTable,
string $newTable,
string $backup = null,
string $prefix = null)
Renames a table in the database.
JDatabaseDriver
setQuery(
mixed $query,
integer $offset,
integer $limit)
Sets the SQL statement string for later execution.