|
eZ Publish
[trunk]
|
The eZMySQLDB class provides MySQL implementation of the database interface. More...
Inheritance diagram for eZMySQLDB:
Collaboration diagram for eZMySQLDB: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. | |
| eZMySQLDB ($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 | |
| $TempTableList | |
| const | RELATION_FOREIGN_KEY = 5 |
| const | RELATION_FOREIGN_KEY_BIT = 32 |
Private Member Functions | |
| checkCharsetPriv ($charset, &$currentCharset) | |
| connect ($server, $db, $user, $password, $socketPath, $charset=null, $port=false) | |
The eZMySQLDB class provides MySQL implementation of the database interface.
eZMySQLDB is the MySQL implementation of eZDB.
Definition at line 18 of file ezmysqldb.php.
| eZMySQLDB::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 444 of file ezmysqldb.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 905 of file ezmysqldb.php.
The query to start the transaction.
Reimplemented from eZDBInterface.
Definition at line 809 of file ezmysqldb.php.
Returns type of binding used in database plugin.
Reimplemented from eZDBInterface.
Definition at line 180 of file ezmysqldb.php.
| eZMySQLDB::bindVariable | ( | $ | value, |
| $ | fieldDef = false |
||
| ) |
Binds variable.
| mixed | $value | |
| mixed | $fieldDef |
Reimplemented from eZDBInterface.
Definition at line 185 of file ezmysqldb.php.
| eZMySQLDB::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 551 of file ezmysqldb.php.
| eZMySQLDB::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 556 of file ezmysqldb.php.
| eZMySQLDB::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 201 of file ezmysqldb.php.
| eZMySQLDB::checkCharsetPriv | ( | $ | charset, |
| &$ | currentCharset | ||
| ) | [private] |
Definition at line 222 of file ezmysqldb.php.
Referenced by checkCharset().
| eZMySQLDB::close | ( | ) |
Will close the database connection.
Reimplemented from eZDBInterface.
Definition at line 853 of file ezmysqldb.php.
The query to commit the transaction.
Reimplemented from eZDBInterface.
Definition at line 817 of file ezmysqldb.php.
| eZMySQLDB::concatString | ( | $ | strings = array() | ) |
Returns a sql-expression(string) to concatenate strings.
| array | $strings |
Reimplemented from eZDBInterface.
Definition at line 540 of file ezmysqldb.php.
| eZMySQLDB::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 82 of file ezmysqldb.php.
Referenced by eZMySQLDB().
| eZMySQLDB::createDatabase | ( | $ | dbName | ) |
Create a new database.
| string | $dbName |
Reimplemented from eZDBInterface.
Definition at line 863 of file ezmysqldb.php.
Returns the version of the database client or false if no version could be retrieved/.
Reimplemented from eZDBInterface.
Definition at line 949 of file ezmysqldb.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 175 of file ezmysqldb.php.
Returns the version of the database server or false if no version could be retrieved/.
Reimplemented from eZDBInterface.
Definition at line 935 of file ezmysqldb.php.
| eZMySQLDB::dropTempTable | ( | $ | dropTableQuery = '', |
| $ | server = self::SERVER_SLAVE |
||
| ) |
Drop temporary table.
| string | $dropTableQuery | |
| int | $server |
Reimplemented from eZDBInterface.
Definition at line 969 of file ezmysqldb.php.
| eZMySQLDB::escapeString | ( | $ | str | ) |
Will escape a string so it's ready to be inserted in the database.
| string | $str |
Reimplemented from eZDBInterface.
Definition at line 841 of file ezmysqldb.php.
| eZMySQLDB::eZMySQLDB | ( | $ | parameters | ) |
Create a new eZMySQLDB object and connects to the database backend.
Connect to master server
Definition at line 26 of file ezmysqldb.php.
| eZMySQLDB::eZTableList | ( | $ | server = eZDBInterface::SERVER_MASTER | ) |
Returns the existing ez publish tables in database.
| int | $server |
Reimplemented from eZDBInterface.
Definition at line 690 of file ezmysqldb.php.
| eZMySQLDB::isCharsetSupported | ( | $ | charset | ) |
Returns true if the charset $charset is supported by the connected database.
| string | $charset |
Reimplemented from eZDBInterface.
Definition at line 959 of file ezmysqldb.php.
Referenced by connect().
| eZMySQLDB::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 830 of file ezmysqldb.php.
| eZMySQLDB::lock | ( | $ | table | ) |
Locks one or several tables.
| string | array | $table |
Reimplemented from eZDBInterface.
Definition at line 773 of file ezmysqldb.php.
| eZMySQLDB::md5 | ( | $ | str | ) |
Returns a sql-expression(string) to generate a md5 sum of the string.
| string | $str |
Reimplemented from eZDBInterface.
Definition at line 546 of file ezmysqldb.php.
| eZMySQLDB::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 270 of file ezmysqldb.php.
Referenced by arrayQuery(), beginQuery(), commitQuery(), createDatabase(), lock(), removeDatabase(), removeRelation(), and unlock().
| eZMySQLDB::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 579 of file ezmysqldb.php.
Referenced by relationCounts().
| eZMySQLDB::relationCounts | ( | $ | relationMask | ) |
Returns the relation count for all relation types in the mask $relationMask.
| int | $relationMask |
Reimplemented from eZDBInterface.
Definition at line 571 of file ezmysqldb.php.
| eZMySQLDB::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 609 of file ezmysqldb.php.
Referenced by relationCount().
| eZMySQLDB::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 724 of file ezmysqldb.php.
| eZMySQLDB::relationName | ( | $ | relationType | ) |
Local eZDBInterface::relationName() override to support the foreign keys type relation.
| $relationType |
Reimplemented from eZDBInterface.
Definition at line 764 of file ezmysqldb.php.
Referenced by removeRelation().
| eZMySQLDB::removeDatabase | ( | $ | dbName | ) |
Removes a database.
| string | $dbName |
Reimplemented from eZDBInterface.
Definition at line 872 of file ezmysqldb.php.
| eZMySQLDB::removeRelation | ( | $ | relationName, |
| $ | relationType | ||
| ) |
Tries to remove the relation type $relationType named $relationName.
| string | $relationName | |
| int | $relationType |
Reimplemented from eZDBInterface.
Definition at line 729 of file ezmysqldb.php.
The query to cancel the transaction.
Reimplemented from eZDBInterface.
Definition at line 825 of file ezmysqldb.php.
| eZMySQLDB::setError | ( | $ | connection = false | ) |
Sets the internal error messages & number.
| int | $connection | database connection handle, overrides the current one if given |
Definition at line 885 of file ezmysqldb.php.
| eZMySQLDB::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 529 of file ezmysqldb.php.
Returns a mask of the relation type it supports.
Reimplemented from eZDBInterface.
Definition at line 561 of file ezmysqldb.php.
Returns an array of the relation types.
Reimplemented from eZDBInterface.
Definition at line 566 of file ezmysqldb.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 964 of file ezmysqldb.php.
Releases table locks.
Reimplemented from eZDBInterface.
Definition at line 798 of file ezmysqldb.php.
| eZMySQLDB::$TempTableList |
Definition at line 975 of file ezmysqldb.php.
| const eZMySQLDB::RELATION_FOREIGN_KEY = 5 |
Definition at line 20 of file ezmysqldb.php.
| const eZMySQLDB::RELATION_FOREIGN_KEY_BIT = 32 |
Definition at line 21 of file ezmysqldb.php.
Referenced by supportedRelationTypeMask().