Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | List of all members
eZMySQLiDB Class Reference
Database abstraction layer

The eZMySQLiDB class provides MySQL implementation of the database interface. More...

Inheritance diagram for eZMySQLiDB:

## Public Member Functions
| __construct ( $parameters)
| databaseName ()
| bindingType ()
| bindVariable ( $value, $fieldDef=false)
| checkCharset ( $charset, &$currentCharset)
| query ( $sql, $server=false)
| arrayQuery ( $sql, $params=array(), $server=false)
| subString ( $string, $from, $len=null)
| concatString ( $strings=array())
| md5 ( $str)
| bitAnd ( $arg1, $arg2)
| bitOr ( $arg1, $arg2)
| supportedRelationTypeMask ()
| supportedRelationTypes ()
| relationCounts ( $relationMask)
| relationCount ( $relationType=eZDBInterface::RELATION_TABLE)
| relationList ( $relationType=eZDBInterface::RELATION_TABLE)
| eZTableList ( $server=eZDBInterface::SERVER_MASTER)
| relationMatchRegexp ( $relationType)
| removeRelation ( $relationName, $relationType)
| relationName ( $relationType)
| lock ( $table)
| unlock ()
| beginQuery ()
| commitQuery ()
| rollbackQuery ()
| lastSerialID ( $table=false, $column=false)
| escapeString ( $str)
| close ()
| createDatabase ( $dbName)
| removeDatabase ( $dbName)
| setError ( $connection=false)
| availableDatabases ()
| databaseServerVersion ()
| databaseClientVersion ()
| isCharsetSupported ( $charset)
| supportsDefaultValuesInsertion ()
| dropTempTable ( $dropTableQuery='', $server=self::SERVER_SLAVE)
Public Member Functions inherited from eZDBInterface
| attributes ()
| hasAttribute ( $name)
| attribute ( $name)
| prepareSqlQuery (&$fd, &$buffer)
| insertFile ( $path, $sqlFile, $usePathType=true)
| reportQuery ( $class, $sql, $numRows, $timeTaken, $asDebug=false)
| setIsSQLOutputEnabled ( $enabled)
| startTimer ()
| endTimer ()
| startTime ()
| endTime ()
| timeTaken ()
| socketPath ()
| connectRetryCount ()
| connectRetryWaitTime ()
| useShortNames ()
| hasRequiredServerVersion ( $minVersion, $name=false)
| charset ()
| usesBuiltinEncoding ()
| begin ()
| commit ()
| rollback ()
| generateFailedTransactionStack ()
| generateFailedTransactionStackEntry ( $stack, $indentCount)
| generateTraceEntry ( $entry)
| invalidateTransaction ()
| reportError ()
| isTransactionValid ()
| transactionCounter ()
| implodeWithTypeCast ( $glue, &$pieces, $type)
| isConnected ()
| createTempTable ( $createTableQuery='', $server=self::SERVER_SLAVE)
| dropTempTableList ( $tableList, $server=self::SERVER_SLAVE)
| setError ()
| errorMessage ()
| errorNumber ()
| generateUniqueTempTableName ( $pattern, $randomizeIndex=false, $server=self::SERVER_SLAVE)
| version ()
| generateSQLINStatement ( $elements, $columnName='', $not=false, $unique=true, $type=false)
| setErrorHandling ( $errorHandling)
| truncateString ( $string, $maxLength, $fieldName, $truncationSuffix='')
| countStringSize ( $string)

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

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

## Private Member Functions
| connect ( $server, $db, $user, $password, $socketPath, $charset=null, $port=false)
| checkCharsetPriv ( $charset, &$currentCharset)

## Detailed Description

The eZMySQLiDB class provides MySQL implementation of the database interface.

eZMySQLiDB is the MySQL implementation of eZDB.

See also
  eZDB

Definition at line 20 of file ezmysqlidb.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZMySQLiDB::__construct | ( |  | $parameters | ) |

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

Parameters

  array | $parameters |

Connect to master server

Reimplemented from eZDBInterface.

Definition at line 30 of file ezmysqlidb.php.

References eZDBInterface\$DBWriteConnection, connect(), eZDebug\createAccumulatorGroup(), eZDBInterface\ERROR_MISSING_EXTENSION, and eZDebug\writeWarning().

## Member Function Documentation

## ◆ arrayQuery()

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 ) );`

Parameters

  string | $sql | SQL query to execute.
  array | $params | Associative array containing extra parameters, can contain: offset -> The offset of the query. limit -> The limit of the query. column - Limit returned row arrays to only contain this column.
  int | bool | $server | Which server to execute the query on, either eZDBInterface::SERVER_MASTER or eZDBInterface::SERVER_SLAVE

Returns
  array

Reimplemented from eZDBInterface.

Definition at line 440 of file ezmysqlidb.php.

References eZDebug\accumulatorStart(), eZDebug\accumulatorStop(), query(), and eZDBInterface\reportQuery().

## ◆ availableDatabases()

eZMySQLiDB::availableDatabases | ( |  | ) |

Returns an array of available databases in the database, null of none available, false if listing databases not supported by database

Returns
  array|null|bool

Reimplemented from eZDBInterface.

Definition at line 908 of file ezmysqlidb.php.

References eZDBInterface\errorNumber().

## ◆ beginQuery()

eZMySQLiDB::beginQuery | ( |  | ) |

The query to start the transaction.

Reimplemented from eZDBInterface.

Definition at line 799 of file ezmysqlidb.php.

References query().

## ◆ bindingType()

eZMySQLiDB::bindingType | ( |  | ) |

Returns type of binding used in database plugin.

Returns
  int

Reimplemented from eZDBInterface.

Definition at line 175 of file ezmysqlidb.php.

References eZDBInterface\BINDING_NO.

## ◆ bindVariable()

eZMySQLiDB::bindVariable | ( |  | $value,
|  |  | $fieldDef = `false`
| ) |  |

Binds variable.

Parameters

  mixed | $value |
  mixed | $fieldDef |

Returns
  mixed

Reimplemented from eZDBInterface.

Definition at line 180 of file ezmysqlidb.php.

## ◆ bitAnd()

eZMySQLiDB::bitAnd | ( |  | $arg1,
|  |  | $arg2
| ) |  |

Returns a sql-expression(string) to generate a bit and of the argument.

Parameters

  string | $arg1 |
  string | $arg2 |

Returns
  string

Reimplemented from eZDBInterface.

Definition at line 547 of file ezmysqlidb.php.

## ◆ bitOr()

eZMySQLiDB::bitOr | ( |  | $arg1,
|  |  | $arg2
| ) |  |

Returns a sql-expression(string) to generate a bit and of the argument.

Parameters

  string | $arg1 |
  string | $arg2 |

Returns
  string

Reimplemented from eZDBInterface.

Definition at line 552 of file ezmysqlidb.php.

## ◆ checkCharset()

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] | $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 193 of file ezmysqlidb.php.

References checkCharsetPriv(), databaseServerVersion(), and eZCharsetInfo\realCharsetCode().

## ◆ checkCharsetPriv()

eZMySQLiDB::checkCharsetPriv | ( |  | $charset,
|  | & | $currentCharset
| ) |  |
| private

Definition at line 216 of file ezmysqlidb.php.

References eZMySQLCharset\mapFrom(), eZCharsetInfo\realCharsetCode(), eZDBInterface\reportQuery(), eZDBInterface\setError(), and eZDebug\writeWarning().

Referenced by checkCharset().

## ◆ close()

eZMySQLiDB::close | ( |  | ) |

Will close the database connection.

Returns
  void

Reimplemented from eZDBInterface.

Definition at line 856 of file ezmysqlidb.php.

## ◆ commitQuery()

eZMySQLiDB::commitQuery | ( |  | ) |

The query to commit the transaction.

Reimplemented from eZDBInterface.

Definition at line 807 of file ezmysqlidb.php.

References query().

## ◆ concatString()

eZMySQLiDB::concatString | ( |  | $strings = `array()` | ) |

Returns a sql-expression(string) to concatenate strings.

Parameters

  array | $strings |

Returns
  string

Reimplemented from eZDBInterface.

Definition at line 536 of file ezmysqlidb.php.

## ◆ connect()

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 86 of file ezmysqlidb.php.

References eZDebug\accumulatorStart(), eZDebug\accumulatorStop(), eZDBInterface\connectRetryCount(), eZDBInterface\connectRetryWaitTime(), eZDebug\HANDLE_EXCEPTION, eZMySQLCharset\mapTo(), eZCharsetInfo\realCharsetCode(), eZDBInterface\setError(), eZDebug\setHandleType(), eZDebug\writeError(), and eZDebug\writeWarning().

Referenced by __construct().

## ◆ createDatabase()

eZMySQLiDB::createDatabase | ( |  | $dbName | ) |

Create a new database

Parameters

  string | $dbName |

Returns
  void

Reimplemented from eZDBInterface.

Definition at line 866 of file ezmysqlidb.php.

References query(), and eZDBInterface\setError().

## ◆ databaseClientVersion()

eZMySQLiDB::databaseClientVersion | ( |  | ) |

Returns the version of the database client or false if no version could be retrieved/

Returns
  string|bool

Reimplemented from eZDBInterface.

Definition at line 952 of file ezmysqlidb.php.

## ◆ databaseName()

eZMySQLiDB::databaseName | ( |  | ) |

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'.

Returns
  string

Reimplemented from eZDBInterface.

Definition at line 170 of file ezmysqlidb.php.

## ◆ databaseServerVersion()

eZMySQLiDB::databaseServerVersion | ( |  | ) |

Returns the version of the database server or false if no version could be retrieved/

Returns
  string|bool

Reimplemented from eZDBInterface.

Definition at line 937 of file ezmysqlidb.php.

Referenced by checkCharset().

## ◆ dropTempTable()

eZMySQLiDB::dropTempTable | ( |  | $dropTableQuery = `''`,
|  |  | $server = `self::SERVER_SLAVE`
| ) |  |

Drop temporary table

Parameters

  string | $dropTableQuery |
  int | $server |

Returns
  void

Reimplemented from eZDBInterface.

Definition at line 972 of file ezmysqlidb.php.

## ◆ escapeString()

eZMySQLiDB::escapeString | ( |  | $str | ) |

Will escape a string so it's ready to be inserted in the database.

Parameters

  string | $str |

Returns
  string mixed

Reimplemented from eZDBInterface.

Definition at line 838 of file ezmysqlidb.php.

References eZDebug\writeDebug().

## ◆ eZTableList()

eZMySQLiDB::eZTableList | ( |  | $server = `eZDBInterface::SERVER_MASTER` | ) |

Returns the existing ez publish tables in database

Parameters

  int | $server |

Returns
  array

Reimplemented from eZDBInterface.

Definition at line 683 of file ezmysqlidb.php.

References eZDBInterface\$DB, eZDBInterface\$DBConnection, eZDBInterface\$DBWriteConnection, eZDBInterface\$SlaveDB, eZDBInterface\RELATION_TABLE, eZDBInterface\reportQuery(), and eZDBInterface\SERVER_SLAVE.

## ◆ isCharsetSupported()

eZMySQLiDB::isCharsetSupported | ( |  | $charset | ) |

Returns true if the charset $charset is supported by the connected database.

Parameters

  string | $charset |

Returns
  bool

Reimplemented from eZDBInterface.

Definition at line 962 of file ezmysqlidb.php.

## ◆ lastSerialID()

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

Reimplemented from eZDBInterface.

Definition at line 827 of file ezmysqlidb.php.

## ◆ lock()

eZMySQLiDB::lock | ( |  | $table | ) |

Locks one or several tables

Parameters

  string | array | $table |

Reimplemented from eZDBInterface.

Definition at line 763 of file ezmysqlidb.php.

References query().

## ◆ md5()

eZMySQLiDB::md5 | ( |  | $str | ) |

Returns a sql-expression(string) to generate a md5 sum of the string.

Parameters

  string | $str |

Returns
  string

Reimplemented from eZDBInterface.

Definition at line 542 of file ezmysqlidb.php.

## ◆ query()

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.

Parameters

  string | $sql | SQL query to execute.
  int | bool | $server |

Returns
  mixed

Reimplemented from eZDBInterface.

Definition at line 264 of file ezmysqlidb.php.

References eZDBInterface\$RecordError, eZDebug\accumulatorStart(), eZDebug\accumulatorStop(), eZDBInterface\endTimer(), eZDB\ERROR_HANDLING_STANDARD, eZDBInterface\reportError(), eZDBInterface\reportQuery(), eZDBInterface\SERVER_MASTER, eZDBInterface\SERVER_SLAVE, eZDBInterface\setError(), eZDBInterface\startTimer(), eZDBInterface\timeTaken(), and eZDebug\writeError().

Referenced by arrayQuery(), beginQuery(), commitQuery(), createDatabase(), lock(), removeDatabase(), removeRelation(), and unlock().

## ◆ relationCount()

eZMySQLiDB::relationCount | ( |  | $relationType = `eZDBInterface::RELATION_TABLE` | ) |

Returns the number of relation objects in the database for the relation type $relationType.

Parameters

  int | $relationType |

Returns
  int

Reimplemented from eZDBInterface.

Definition at line 575 of file ezmysqlidb.php.

References RELATION_FOREIGN_KEY, eZDBInterface\RELATION_TABLE, relationList(), eZDBInterface\reportQuery(), supportedRelationTypes(), and eZDebug\writeError().

Referenced by relationCounts().

## ◆ relationCounts()

eZMySQLiDB::relationCounts | ( |  | $relationMask | ) |

Returns the relation count for all relation types in the mask $relationMask.

Parameters

  int | $relationMask |

Returns
  int

Reimplemented from eZDBInterface.

Definition at line 567 of file ezmysqlidb.php.

References eZDBInterface\RELATION_TABLE_BIT, and relationCount().

## ◆ relationList()

eZMySQLiDB::relationList | ( |  | $relationType = `eZDBInterface::RELATION_TABLE` | ) |

Returns the relation names in the database as an array for the relation type $relationType.

Parameters

  int | $relationType |

Returns
  array

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 605 of file ezmysqlidb.php.

References RELATION_FOREIGN_KEY, eZDBInterface\RELATION_TABLE, eZDBInterface\reportQuery(), supportedRelationTypes(), and eZDebug\writeError().

Referenced by relationCount().

## ◆ relationMatchRegexp()

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).

Parameters

  int | $relationType | The type which needs to be filtered, this allows one regexp per type.

Returns
  bool

Reimplemented from eZDBInterface.

Definition at line 715 of file ezmysqlidb.php.

## ◆ relationName()

eZMySQLiDB::relationName | ( |  | $relationType | ) |

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

Parameters

  $relationType |

Returns
  string|false

Reimplemented from eZDBInterface.

Definition at line 755 of file ezmysqlidb.php.

Referenced by removeRelation().

## ◆ removeDatabase()

eZMySQLiDB::removeDatabase | ( |  | $dbName | ) |

Removes a database

Parameters

  string | $dbName |

Returns
  void

Reimplemented from eZDBInterface.

Definition at line 875 of file ezmysqlidb.php.

References query(), and eZDBInterface\setError().

## ◆ removeRelation()

eZMySQLiDB::removeRelation | ( |  | $relationName,
|  |  | $relationType
| ) |  |

Tries to remove the relation type $relationType named $relationName

Parameters

  string | $relationName |
  int | $relationType |

Returns
  bool true if successful

Reimplemented from eZDBInterface.

Definition at line 720 of file ezmysqlidb.php.

References query(), RELATION_FOREIGN_KEY, relationName(), and eZDebug\writeError().

## ◆ rollbackQuery()

eZMySQLiDB::rollbackQuery | ( |  | ) |

The query to cancel the transaction.

Reimplemented from eZDBInterface.

Definition at line 815 of file ezmysqlidb.php.

## ◆ setError()

eZMySQLiDB::setError | ( |  | $connection = `false` | ) |

Sets the internal error messages & number

Parameters

  MySQLi | $connection | database connection handle, overrides the current one if given

Definition at line 888 of file ezmysqlidb.php.

References eZDBInterface\$DBConnection.

## ◆ subString()

eZMySQLiDB::subString | ( |  | $string,
|  |  | $from,
|  |  | $len = `null`
| ) |  |

Returns a sql-expression(string) to get substring.

Parameters

  string | $string |
  int | $from |
  int | $len |

Returns
  string

Reimplemented from eZDBInterface.

Definition at line 525 of file ezmysqlidb.php.

## ◆ supportedRelationTypeMask()

eZMySQLiDB::supportedRelationTypeMask | ( |  | ) |

Returns a mask of the relation type it supports.

Returns
  int

Reimplemented from eZDBInterface.

Definition at line 557 of file ezmysqlidb.php.

References RELATION_FOREIGN_KEY_BIT, and eZDBInterface\RELATION_TABLE_BIT.

## ◆ supportedRelationTypes()

eZMySQLiDB::supportedRelationTypes | ( |  | ) |

Returns an array of the relation types.

Returns
  array

Reimplemented from eZDBInterface.

Definition at line 562 of file ezmysqlidb.php.

References eZDBInterface\RELATION_TABLE.

Referenced by relationCount(), and relationList().

## ◆ supportsDefaultValuesInsertion()

eZMySQLiDB::supportsDefaultValuesInsertion | ( |  | ) |

Returns true if the database handler support the insertion of default values, false if not

Returns
  bool

Reimplemented from eZDBInterface.

Definition at line 967 of file ezmysqlidb.php.

## ◆ unlock()

eZMySQLiDB::unlock | ( |  | ) |

Releases table locks.

Returns
  void

Reimplemented from eZDBInterface.

Definition at line 788 of file ezmysqlidb.php.

References query().

## Member Data Documentation

## ◆ $TempTableList

eZMySQLiDB::$TempTableList
| protected

Definition at line 978 of file ezmysqlidb.php.

## ◆ RELATION_FOREIGN_KEY

const eZMySQLiDB::RELATION_FOREIGN_KEY = 5

Definition at line 22 of file ezmysqlidb.php.

Referenced by relationCount(), relationList(), and removeRelation().

## ◆ RELATION_FOREIGN_KEY_BIT

const eZMySQLiDB::RELATION_FOREIGN_KEY_BIT = 32

Definition at line 23 of file ezmysqlidb.php.

Referenced by supportedRelationTypeMask().

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

- ezmysqlidb.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.