|
eZ Publish
[trunk]
|
The eZMySQLiDB class provides MySQL implementation of the database interface. More...
Inheritance diagram for eZMySQLiDB:
Collaboration diagram for eZMySQLiDB:Public Member Functions | |
| arrayQuery ($sql, $params=array(), $server=false) | |
| Executes an SQL query and returns the result as an array of accociative arrays. | |
| availableDatabases () | |
| Returns an array of available databases in the database, null of none available, false if listing databases not supported by database. | |
| beginQuery () | |
| bindingType () | |
| Returns type of binding used in database plugin. | |
| bindVariable ($value, $fieldDef=false) | |
| Binds variable. | |
| bitAnd ($arg1, $arg2) | |
| Returns a sql-expression(string) to generate a bit and of the argument. | |
| bitOr ($arg1, $arg2) | |
| Returns a sql-expression(string) to generate a bit and of the argument. | |
| checkCharset ($charset, &$currentCharset) | |
| close () | |
| Will close the database connection. | |
| commitQuery () | |
| concatString ($strings=array()) | |
| Returns a sql-expression(string) to concatenate strings. | |
| createDatabase ($dbName) | |
| Create a new database. | |
| databaseClientVersion () | |
| Returns the version of the database client or false if no version could be retrieved/. | |
| databaseName () | |
| Returns the name of driver, this is used to determine the name of the database type. | |
| databaseServerVersion () | |
| Returns the version of the database server or false if no version could be retrieved/. | |
| dropTempTable ($dropTableQuery= '', $server=self::SERVER_SLAVE) | |
| Drop temporary table. | |
| escapeString ($str) | |
| Will escape a string so it's ready to be inserted in the database. | |
| eZMySQLiDB ($parameters) | |
| eZTableList ($server=eZDBInterface::SERVER_MASTER) | |
| Returns the existing ez publish tables in database. | |
| isCharsetSupported ($charset) | |
| Returns true if the charset $charset is supported by the connected database. | |
| lastSerialID ($table=false, $column=false) | |
| Returns the last serial ID generated with an auto increment field. | |
| lock ($table) | |
| Locks one or several tables. | |
| md5 ($str) | |
| Returns a sql-expression(string) to generate a md5 sum of the string. | |
| query ($sql, $server=false) | |
| Execute a query on the global MySQL database link. | |
| relationCount ($relationType=eZDBInterface::RELATION_TABLE) | |
| Returns the number of relation objects in the database for the relation type $relationType. | |
| relationCounts ($relationMask) | |
| Returns the relation count for all relation types in the mask $relationMask. | |
| relationList ($relationType=eZDBInterface::RELATION_TABLE) | |
| Returns the relation names in the database as an array for the relation type $relationType. | |
| relationMatchRegexp ($relationType) | |
| Return A regexp (PCRE) that can be used to filter out certain relation elements. | |
| relationName ($relationType) | |
| Local eZDBInterface::relationName() override to support the foreign keys type relation. | |
| removeDatabase ($dbName) | |
| Removes a database. | |
| removeRelation ($relationName, $relationType) | |
| Tries to remove the relation type $relationType named $relationName. | |
| rollbackQuery () | |
| setError ($connection=false) | |
| Sets the internal error messages & number. | |
| subString ($string, $from, $len=null) | |
| Returns a sql-expression(string) to get substring. | |
| supportedRelationTypeMask () | |
| Returns a mask of the relation type it supports. | |
| supportedRelationTypes () | |
| Returns an array of the relation types. | |
| supportsDefaultValuesInsertion () | |
| Returns true if the database handler support the insertion of default values, false if not. | |
| unlock () | |
| Releases table locks. | |
Public Attributes | |
| const | RELATION_FOREIGN_KEY = 5 |
| const | RELATION_FOREIGN_KEY_BIT = 32 |
Protected Attributes | |
| $TempTableList | |
Private Member Functions | |
| checkCharsetPriv ($charset, &$currentCharset) | |
| connect ($server, $db, $user, $password, $socketPath, $charset=null, $port=false) | |
The eZMySQLiDB class provides MySQL implementation of the database interface.
eZMySQLiDB is the MySQL implementation of eZDB.
Definition at line 20 of file ezmysqlidb.php.
| eZMySQLiDB::arrayQuery | ( | $ | sql, |
| $ | params = array(), |
||
| $ | server = false |
||
| ) |
Executes an SQL query and returns the result as an array of accociative arrays.
Example: $db->arrayQuery( 'SELECT * FROM eztable', array( 'limit' => 10, 'offset' => 5 ) );
| string | $sql | SQL query to execute. |
| array | $params | Associative array containing extra parameters, can contain:
|
| int | bool | $server | Which server to execute the query on, either eZDBInterface::SERVER_MASTER or eZDBInterface::SERVER_SLAVE |
Reimplemented from eZDBInterface.
Definition at line 437 of file ezmysqlidb.php.
Returns an array of available databases in the database, null of none available, false if listing databases not supported by database.
Reimplemented from eZDBInterface.
Definition at line 893 of file ezmysqlidb.php.
The query to start the transaction.
Reimplemented from eZDBInterface.
Definition at line 796 of file ezmysqlidb.php.
Returns type of binding used in database plugin.
Reimplemented from eZDBInterface.
Definition at line 173 of file ezmysqlidb.php.
| eZMySQLiDB::bindVariable | ( | $ | value, |
| $ | fieldDef = false |
||
| ) |
Binds variable.
| mixed | $value | |
| mixed | $fieldDef |
Reimplemented from eZDBInterface.
Definition at line 178 of file ezmysqlidb.php.
| eZMySQLiDB::bitAnd | ( | $ | arg1, |
| $ | arg2 | ||
| ) |
Returns a sql-expression(string) to generate a bit and of the argument.
| string | $arg1 | |
| string | $arg2 |
Reimplemented from eZDBInterface.
Definition at line 544 of file ezmysqlidb.php.
| eZMySQLiDB::bitOr | ( | $ | arg1, |
| $ | arg2 | ||
| ) |
Returns a sql-expression(string) to generate a bit and of the argument.
| string | $arg1 | |
| string | $arg2 |
Reimplemented from eZDBInterface.
Definition at line 549 of file ezmysqlidb.php.
| eZMySQLiDB::checkCharset | ( | $ | charset, |
| &$ | currentCharset | ||
| ) |
Checks if the requested character set matches the one used in the database.
true if it matches or false if it differs. | [out] | $currentCharset | The charset that the database uses. will only be set if the match fails. Note: This will be specific to the database. |
Reimplemented from eZDBInterface.
Definition at line 191 of file ezmysqlidb.php.
| eZMySQLiDB::checkCharsetPriv | ( | $ | charset, |
| &$ | currentCharset | ||
| ) | [private] |
Definition at line 214 of file ezmysqlidb.php.
Referenced by checkCharset().
Will close the database connection.
Reimplemented from eZDBInterface.
Definition at line 841 of file ezmysqlidb.php.
The query to commit the transaction.
Reimplemented from eZDBInterface.
Definition at line 804 of file ezmysqlidb.php.
| eZMySQLiDB::concatString | ( | $ | strings = array() | ) |
Returns a sql-expression(string) to concatenate strings.
| array | $strings |
Reimplemented from eZDBInterface.
Definition at line 533 of file ezmysqlidb.php.
| eZMySQLiDB::connect | ( | $ | server, |
| $ | db, | ||
| $ | user, | ||
| $ | password, | ||
| $ | socketPath, | ||
| $ | charset = null, |
||
| $ | port = false |
||
| ) | [private] |
Opens a new connection to a MySQL database and returns the connection
Definition at line 84 of file ezmysqlidb.php.
Referenced by eZMySQLiDB().
| eZMySQLiDB::createDatabase | ( | $ | dbName | ) |
Create a new database.
| string | $dbName |
Reimplemented from eZDBInterface.
Definition at line 851 of file ezmysqlidb.php.
Returns the version of the database client or false if no version could be retrieved/.
Reimplemented from eZDBInterface.
Definition at line 937 of file ezmysqlidb.php.
Returns the name of driver, this is used to determine the name of the database type.
For instance multiple implementations of the MySQL database will all return 'mysql'.
Reimplemented from eZDBInterface.
Definition at line 168 of file ezmysqlidb.php.
Returns the version of the database server or false if no version could be retrieved/.
Reimplemented from eZDBInterface.
Definition at line 922 of file ezmysqlidb.php.
Referenced by checkCharset().
| eZMySQLiDB::dropTempTable | ( | $ | dropTableQuery = '', |
| $ | server = self::SERVER_SLAVE |
||
| ) |
Drop temporary table.
| string | $dropTableQuery | |
| int | $server |
Reimplemented from eZDBInterface.
Definition at line 957 of file ezmysqlidb.php.
| eZMySQLiDB::escapeString | ( | $ | str | ) |
Will escape a string so it's ready to be inserted in the database.
| string | $str |
Reimplemented from eZDBInterface.
Definition at line 828 of file ezmysqlidb.php.
| eZMySQLiDB::eZMySQLiDB | ( | $ | parameters | ) |
Create a new eZMySQLiDB object and connects to the database backend.
Connect to master server
Definition at line 28 of file ezmysqlidb.php.
| eZMySQLiDB::eZTableList | ( | $ | server = eZDBInterface::SERVER_MASTER | ) |
Returns the existing ez publish tables in database.
| int | $server |
Reimplemented from eZDBInterface.
Definition at line 680 of file ezmysqlidb.php.
| eZMySQLiDB::isCharsetSupported | ( | $ | charset | ) |
Returns true if the charset $charset is supported by the connected database.
| string | $charset |
Reimplemented from eZDBInterface.
Definition at line 947 of file ezmysqlidb.php.
| eZMySQLiDB::lastSerialID | ( | $ | table = false, |
| $ | column = false |
||
| ) |
Returns the last serial ID generated with an auto increment field.
| string | bool | $table | |
| string | bool | $column |
Reimplemented from eZDBInterface.
Definition at line 817 of file ezmysqlidb.php.
| eZMySQLiDB::lock | ( | $ | table | ) |
Locks one or several tables.
| string | array | $table |
Reimplemented from eZDBInterface.
Definition at line 760 of file ezmysqlidb.php.
| eZMySQLiDB::md5 | ( | $ | str | ) |
Returns a sql-expression(string) to generate a md5 sum of the string.
| string | $str |
Reimplemented from eZDBInterface.
Definition at line 539 of file ezmysqlidb.php.
| eZMySQLiDB::query | ( | $ | sql, |
| $ | server = false |
||
| ) |
Execute a query on the global MySQL database link.
If it returns an error, the script is halted and the attempted SQL query and MySQL error message are printed.
| string | $sql | SQL query to execute. |
| int | bool | $server |
Reimplemented from eZDBInterface.
Definition at line 262 of file ezmysqlidb.php.
Referenced by arrayQuery(), beginQuery(), commitQuery(), createDatabase(), lock(), removeDatabase(), removeRelation(), and unlock().
| eZMySQLiDB::relationCount | ( | $ | relationType = eZDBInterface::RELATION_TABLE | ) |
Returns the number of relation objects in the database for the relation type $relationType.
| int | $relationType |
Reimplemented from eZDBInterface.
Definition at line 572 of file ezmysqlidb.php.
Referenced by relationCounts().
| eZMySQLiDB::relationCounts | ( | $ | relationMask | ) |
Returns the relation count for all relation types in the mask $relationMask.
| int | $relationMask |
Reimplemented from eZDBInterface.
Definition at line 564 of file ezmysqlidb.php.
| eZMySQLiDB::relationList | ( | $ | relationType = eZDBInterface::RELATION_TABLE | ) |
Returns the relation names in the database as an array for the relation type $relationType.
| int | $relationType |
Ideally, we would have queried information_schema.KEY_COLUMN_USAGE However, a known bug causes queries on this table to potentially be VERY slow (http://bugs.mysql.com/bug.php?id=19588)
The query would look like this: SELECT table_name AS from_table, column_name AS from_column, referenced_table_name AS to_table, referenced_column_name AS to_column FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '{$this->DB}' AND REFERENCED_TABLE_NAME is not null;
Result as of MySQL 5.1.48 / August 2010:
+---------------+-------------+----------+-----------+ | from_table | from_column | to_table | to_column | +---------------+-------------+----------+-----------+ | ezdbfile_data | name_hash | ezdbfile | name_hash | +---------------+-------------+----------+-----------+ 1 row in set (12.56 sec)
The only way out right now is to parse SHOW CREATE TABLE for each table and extract CONSTRAINT lines
Reimplemented from eZDBInterface.
Definition at line 602 of file ezmysqlidb.php.
Referenced by relationCount().
| eZMySQLiDB::relationMatchRegexp | ( | $ | relationType | ) |
Return A regexp (PCRE) that can be used to filter out certain relation elements.
If no special regexp is provided it will return false.
An example, will only match tables that start with 'ez'. return "#^ez#";
This function is currently used by the eZDBTool class to remove relation elements of a specific kind (Most likely eZ Publish related elements).
| int | $relationType | The type which needs to be filtered, this allows one regexp per type. |
Reimplemented from eZDBInterface.
Definition at line 712 of file ezmysqlidb.php.
| eZMySQLiDB::relationName | ( | $ | relationType | ) |
Local eZDBInterface::relationName() override to support the foreign keys type relation.
| $relationType |
Reimplemented from eZDBInterface.
Definition at line 752 of file ezmysqlidb.php.
Referenced by removeRelation().
| eZMySQLiDB::removeDatabase | ( | $ | dbName | ) |
Removes a database.
| string | $dbName |
Reimplemented from eZDBInterface.
Definition at line 860 of file ezmysqlidb.php.
| eZMySQLiDB::removeRelation | ( | $ | relationName, |
| $ | relationType | ||
| ) |
Tries to remove the relation type $relationType named $relationName.
| string | $relationName | |
| int | $relationType |
Reimplemented from eZDBInterface.
Definition at line 717 of file ezmysqlidb.php.
The query to cancel the transaction.
Reimplemented from eZDBInterface.
Definition at line 812 of file ezmysqlidb.php.
| eZMySQLiDB::setError | ( | $ | connection = false | ) |
Sets the internal error messages & number.
| MySQLi | $connection | database connection handle, overrides the current one if given |
Definition at line 873 of file ezmysqlidb.php.
| eZMySQLiDB::subString | ( | $ | string, |
| $ | from, | ||
| $ | len = null |
||
| ) |
Returns a sql-expression(string) to get substring.
| string | $string | |
| int | $from | |
| int | $len |
Reimplemented from eZDBInterface.
Definition at line 522 of file ezmysqlidb.php.
Returns a mask of the relation type it supports.
Reimplemented from eZDBInterface.
Definition at line 554 of file ezmysqlidb.php.
Returns an array of the relation types.
Reimplemented from eZDBInterface.
Definition at line 559 of file ezmysqlidb.php.
Referenced by relationCount(), and relationList().
Returns true if the database handler support the insertion of default values, false if not.
Reimplemented from eZDBInterface.
Definition at line 952 of file ezmysqlidb.php.
Releases table locks.
Reimplemented from eZDBInterface.
Definition at line 785 of file ezmysqlidb.php.
eZMySQLiDB::$TempTableList [protected] |
Definition at line 963 of file ezmysqlidb.php.
| const eZMySQLiDB::RELATION_FOREIGN_KEY = 5 |
Definition at line 22 of file ezmysqlidb.php.
| const eZMySQLiDB::RELATION_FOREIGN_KEY_BIT = 32 |
Definition at line 23 of file ezmysqlidb.php.
Referenced by supportedRelationTypeMask().