eZPublishCommunityProject(LegacyStack)  2013.6
eZMySQLiDB Class Reference

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)
 
 availableDatabases ()
 
 beginQuery ()
 
 bindingType ()
 
 bindVariable ($value, $fieldDef=false)
 
 bitAnd ($arg1, $arg2)
 
 bitOr ($arg1, $arg2)
 
 checkCharset ($charset, &$currentCharset)
 
 close ()
 
 commitQuery ()
 
 concatString ($strings=array())
 
 createDatabase ($dbName)
 
 databaseClientVersion ()
 
 databaseName ()
 
 databaseServerVersion ()
 
 dropTempTable ($dropTableQuery= '', $server=self::SERVER_SLAVE)
 
 escapeString ($str)
 
 eZMySQLiDB ($parameters)
 
 eZTableList ($server=eZDBInterface::SERVER_MASTER)
 
 isCharsetSupported ($charset)
 
 lastSerialID ($table=false, $column=false)
 Returns the last serial ID generated with an auto increment field. More...
 
 lock ($table)
 
 md5 ($str)
 
 query ($sql, $server=false)
 
 relationCount ($relationType=eZDBInterface::RELATION_TABLE)
 
 relationCounts ($relationMask)
 
 relationList ($relationType=eZDBInterface::RELATION_TABLE)
 
 relationMatchRegexp ($relationType)
 
 relationName ($relationType)
 Local eZDBInterface::relationName() override to support the foreign keys type relation. More...
 
 removeDatabase ($dbName)
 
 removeRelation ($relationName, $relationType)
 
 rollbackQuery ()
 
 setError ($connection=false)
 Sets the internal error messages & number. More...
 
 subString ($string, $from, $len=null)
 
 supportedRelationTypeMask ()
 
 supportedRelationTypes ()
 
 supportsDefaultValuesInsertion ()
 
 unlock ()
 
- Public Member Functions inherited from eZDBInterface
 arrayQuery ($sql, $params=array(), $server=false)
 Executes an SQL query and returns the result as an array of accociative arrays. More...
 
 attribute ($name)
 Returns the value of the attribute $name if it exists, otherwise null. More...
 
 attributes ()
 Returns the available attributes for this database handler. More...
 
 availableDatabases ()
 Returns an array of available databases in the database, null of none available, false if listing databases not supported by database. More...
 
 begin ()
 Begin a new transaction. More...
 
 beginQuery ()
 The query to start a transaction. More...
 
 bindingType ()
 Returns type of binding used in database plugin. More...
 
 bindVariable ($value, $fieldDef=false)
 Binds variable. More...
 
 bitAnd ($arg1, $arg2)
 Returns a sql-expression(string) to generate a bit and of the argument. More...
 
 bitOr ($arg1, $arg2)
 Returns a sql-expression(string) to generate a bit and of the argument. More...
 
 charset ()
 Returns the charset which the database is encoded in. More...
 
 checkCharset ($charset, &$currentCharset)
 Checks if the requested character set matches the one used in the database. More...
 
 close ()
 Will close the database connection. More...
 
 commit ()
 Commits the current transaction. More...
 
 commitQuery ()
 The query to commit the transaction. More...
 
 concatString ($strings=array())
 Returns a sql-expression(string) to concatenate strings. More...
 
 connectRetryCount ()
 Returns the number of times the db handler should try to reconnect if it fails. More...
 
 connectRetryWaitTime ()
 Returns the number of seconds the db handler should wait before rereconnecting. More...
 
 createDatabase ($dbName)
 Create a new database. More...
 
 createTempTable ($createTableQuery= '', $server=self::SERVER_SLAVE)
 Create a new temporary table. More...
 
 databaseClientVersion ()
 Returns the version of the database client or false if no version could be retrieved/. More...
 
 databaseName ()
 Returns the name of driver, this is used to determine the name of the database type. More...
 
 databaseServerVersion ()
 Returns the version of the database server or false if no version could be retrieved/. More...
 
 dropTempTable ($dropTableQuery= '', $server=self::SERVER_SLAVE)
 Drop temporary table. More...
 
 dropTempTableList ($tableList, $server=self::SERVER_SLAVE)
 Drop temporary table list. More...
 
 endTime ()
 Returns the micro time when the timer was ended or false if no timer. More...
 
 endTimer ()
 Stops the current timer and calculates the time taken. More...
 
 errorMessage ()
 Returns the error message. More...
 
 errorNumber ()
 Returns the error number. More...
 
 escapeString ($str)
 Will escape a string so it's ready to be inserted in the database. More...
 
 eZDBInterface ($parameters)
 Creates a new eZDBInterface object and connects to the database backend. More...
 
 eZTableList ($server=self::SERVER_MASTER)
 Returns the existing ez publish tables in database. More...
 
 generateFailedTransactionStack ()
 Goes through the transaction stack tree {. More...
 
 generateFailedTransactionStackEntry ($stack, $indentCount)
 Recursive helper function for generating stack tree output. More...
 
 generateSQLINStatement ($elements, $columnName= '', $not=false, $unique=true, $type=false)
 This function can be used to create a SQL IN statement to be used in a WHERE clause: More...
 
 generateTraceEntry ($entry)
 Helper function for generating output for one stack-trace entry. More...
 
 generateUniqueTempTableName ($pattern, $randomizeIndex=false, $server=self::SERVER_SLAVE)
 Generate unique table name basing on the given pattern. More...
 
 hasAttribute ($name)
 Returns true if the attribute $name exists for this database handler. More...
 
 hasRequiredServerVersion ($minVersion, $name=false)
 Checks if the version number of the server is equal or larger than $minVersion. More...
 
 implodeWithTypeCast ($glue, &$pieces, $type)
 Casts elements of $pieces to type $type and returns them as string separated by $glue. More...
 
 insertFile ($path, $sqlFile, $usePathType=true)
 Inserts the SQL file $sqlFile found in the path $path into the currently connected database. More...
 
 invalidateTransaction ()
 Invalidates the current transaction, see {. More...
 
 isCharsetSupported ($charset)
 Returns true if the charset $charset is supported by the connected database. More...
 
 isConnected ()
 Returns true if we're connected to the database backend. More...
 
 isTransactionValid ()
 Returns if the current or last running transaction is valid. More...
 
 lastSerialID ($table=false, $column=false)
 Returns the last serial ID generated with an auto increment field. More...
 
 lock ($table)
 Locks one or several tables. More...
 
 md5 ($str)
 Returns a sql-expression(string) to generate a md5 sum of the string. More...
 
 prepareSqlQuery (&$fd, &$buffer)
 Prepare the sql file so we can create the database. More...
 
 query ($sql, $server=false)
 Execute a query on the global MySQL database link. More...
 
 relationCount ($relationType=eZDBInterface::RELATION_TABLE)
 Returns the number of relation objects in the database for the relation type $relationType. More...
 
 relationCounts ($relationMask)
 Returns the relation count for all relation types in the mask $relationMask. More...
 
 relationList ($relationType=eZDBInterface::RELATION_TABLE)
 Returns the relation names in the database as an array for the relation type $relationType. More...
 
 relationMatchRegexp ($relationType)
 Return A regexp (PCRE) that can be used to filter out certain relation elements. More...
 
 relationName ($relationType)
 Returns the name of the relation type which is usable in SQL or false if unknown type. More...
 
 removeDatabase ($dbName)
 Removes a database. More...
 
 removeRelation ($relationName, $relationType)
 Tries to remove the relation type $relationType named $relationName. More...
 
 reportError ()
 This is called whenever an error occurs in one of the database handlers. More...
 
 reportQuery ($class, $sql, $numRows, $timeTaken, $asDebug=false)
 Writes a debug notice with query information. More...
 
 rollback ()
 Cancels the transaction. More...
 
 rollbackQuery ()
 The query to cancel the transaction. More...
 
 setError ()
 Sets the error message and error message number. More...
 
 setErrorHandling ($errorHandling)
 Sets the eZDB error handling mode. More...
 
 setIsSQLOutputEnabled ($enabled)
 Enabled or disables sql output. More...
 
 socketPath ()
 Returns the socket path for the database or false if no socket path was defined. More...
 
 startTime ()
 Returns the micro time when the timer was start or false if no timer. More...
 
 startTimer ()
 Records the current micro time. More...
 
 subString ($string, $from, $len=null)
 Returns a sql-expression(string) to get substring. More...
 
 supportedRelationTypeMask ()
 Returns a mask of the relation type it supports. More...
 
 supportedRelationTypes ()
 Returns an array of the relation types. More...
 
 supportsDefaultValuesInsertion ()
 Returns true if the database handler support the insertion of default values, false if not. More...
 
 timeTaken ()
 Returns the number of milliseconds the last operation took or false if no value. More...
 
 transactionCounter ()
 Returns the current transaction counter. More...
 
 unlock ()
 Releases table locks. More...
 
 usesBuiltinEncoding ()
 Returns true if the database handles encoding itself. More...
 
 useShortNames ()
 Returns if the short column names should be used insted of default ones. More...
 
 version ()
 Get database version number. More...
 

Public Attributes

const RELATION_FOREIGN_KEY = 5
 
const RELATION_FOREIGN_KEY_BIT = 32
 
- Public Attributes inherited from eZDBInterface
 $Charset
 
 $ConnectRetries
 
 $DB
 
 $DBConnection
 
 $DBWriteConnection
 
 $EndTime
 
 $ErrorMessage
 
 $ErrorNumber = 0
 
 $InputTextCodec
 
 $IsConnected = false
 
 $NumQueries = 0
 
 $OutputSQL
 
 $OutputTextCodec
 
 $Password
 
 $Port
 
 $RecordError = true
 
 $Server
 
 $SlaveDB
 
 $SlavePassword
 
 $SlavePort
 
 $SlaveServer
 
 $SlaveUser
 
 $SocketPath
 
 $StartTime
 
 $TimeTaken
 
 $TransactionCounter
 
 $TransactionIsValid
 
 $TransactionStackTree
 
 $UseBuiltinEncoding
 
 $UsePersistentConnection = false
 
 $User
 
 $UseSlaveServer
 
const BINDING_NAME = 1
 
const BINDING_NO = 0
 
const BINDING_ORDERED = 2
 
const ERROR_MISSING_EXTENSION = 1
 
const RELATION_INDEX = 4
 
const RELATION_INDEX_BIT = 16
 
const RELATION_MASK = 31
 
const RELATION_NONE = 0
 
const RELATION_SEQUENCE = 1
 
const RELATION_SEQUENCE_BIT = 2
 
const RELATION_TABLE = 0
 
const RELATION_TABLE_BIT = 1
 
const RELATION_TRIGGER = 2
 
const RELATION_TRIGGER_BIT = 4
 
const RELATION_VIEW = 3
 
const RELATION_VIEW_BIT = 8
 
const SERVER_MASTER = 1
 
const SERVER_SLAVE = 2
 

Protected Attributes

 $TempTableList
 
- Protected Attributes inherited from eZDBInterface
 $errorHandling = eZDB::ERROR_HANDLING_STANDARD
 

Private Member Functions

 checkCharsetPriv ($charset, &$currentCharset)
 
 connect ($server, $db, $user, $password, $socketPath, $charset=null, $port=false)
 

Detailed Description

The eZMySQLiDB class provides MySQL implementation of the database interface.

eZMySQLiDB is the MySQL implementation of eZDB.

See Also
eZDB

Member Function Documentation

eZMySQLiDB::arrayQuery (   $sql,
  $params = array(),
  $server = false 
)
eZMySQLiDB::availableDatabases ( )
eZMySQLiDB::beginQuery ( )

The query to start the transaction.

eZMySQLiDB::bindingType ( )
eZMySQLiDB::bindVariable (   $value,
  $fieldDef = false 
)
eZMySQLiDB::bitAnd (   $arg1,
  $arg2 
)
eZMySQLiDB::bitOr (   $arg1,
  $arg2 
)
eZMySQLiDB::checkCharset (   $charset,
$currentCharset 
)

Checks if the requested character set matches the one used in the database.

Returns
true if it matches or false if it differs.
Parameters
[out]$currentCharsetThe charset that the database uses. will only be set if the match fails. Note: This will be specific to the database.
eZMySQLiDB::checkCharsetPriv (   $charset,
$currentCharset 
)
private

Referenced by checkCharset().

eZMySQLiDB::close ( )
eZMySQLiDB::commitQuery ( )

The query to commit the transaction.

eZMySQLiDB::concatString (   $strings = array())
eZMySQLiDB::connect (   $server,
  $db,
  $user,
  $password,
  $socketPath,
  $charset = null,
  $port = false 
)
private

Opens a new connection to a MySQL database and returns the connection

Referenced by eZMySQLiDB().

eZMySQLiDB::createDatabase (   $dbName)
eZMySQLiDB::databaseClientVersion ( )
eZMySQLiDB::databaseName ( )
eZMySQLiDB::databaseServerVersion ( )

Referenced by checkCharset().

eZMySQLiDB::dropTempTable (   $dropTableQuery = '',
  $server = self::SERVER_SLAVE 
)
eZMySQLiDB::escapeString (   $str)
eZMySQLiDB::eZMySQLiDB (   $parameters)

Create a new eZMySQLiDB object and connects to the database backend.

Connect to master server

eZMySQLiDB::eZTableList (   $server = eZDBInterface::SERVER_MASTER)
eZMySQLiDB::isCharsetSupported (   $charset)
eZMySQLiDB::lastSerialID (   $table = false,
  $column = false 
)

Returns the last serial ID generated with an auto increment field.

Parameters
string | bool$table
string | bool$column
Returns
int|bool The most recent value for the sequence
eZMySQLiDB::lock (   $table)
eZMySQLiDB::md5 (   $str)
eZMySQLiDB::query (   $sql,
  $server = false 
)
eZMySQLiDB::relationCount (   $relationType = eZDBInterface::RELATION_TABLE)

Referenced by relationCounts().

eZMySQLiDB::relationCounts (   $relationMask)
eZMySQLiDB::relationList (   $relationType = eZDBInterface::RELATION_TABLE)

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

Referenced by relationCount().

eZMySQLiDB::relationMatchRegexp (   $relationType)
eZMySQLiDB::relationName (   $relationType)

Local eZDBInterface::relationName() override to support the foreign keys type relation.

Parameters
$relationType
Returns
string|false

Referenced by removeRelation().

eZMySQLiDB::removeDatabase (   $dbName)
eZMySQLiDB::removeRelation (   $relationName,
  $relationType 
)
eZMySQLiDB::rollbackQuery ( )

The query to cancel the transaction.

eZMySQLiDB::setError (   $connection = false)

Sets the internal error messages & number.

Parameters
MySQLi$connectiondatabase connection handle, overrides the current one if given
eZMySQLiDB::subString (   $string,
  $from,
  $len = null 
)
eZMySQLiDB::supportedRelationTypeMask ( )
eZMySQLiDB::supportedRelationTypes ( )

Referenced by relationCount(), and relationList().

eZMySQLiDB::supportsDefaultValuesInsertion ( )
eZMySQLiDB::unlock ( )

Member Data Documentation

eZMySQLiDB::$TempTableList
protected
const eZMySQLiDB::RELATION_FOREIGN_KEY = 5
const eZMySQLiDB::RELATION_FOREIGN_KEY_BIT = 32

The documentation for this class was generated from the following file: