ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDBMySQL Class Reference

MySQL Database Wrapper. More...

+ Inheritance diagram for ilDBMySQL:
+ Collaboration diagram for ilDBMySQL:

Public Member Functions

 supportsSlave ()
 Supports slave.
 setDBSlaveActive ($a_val)
 Set slave active.
 getDBSlaveActive ()
 Get slave active.
 setDBSlaveUser ($a_user)
 Set slave database user.
 getDBSlaveUser ()
 Get slave database user.
 setDBSlavePort ($a_port)
 Set slave database port.
 getDBSlavePort ()
 Get slave database port.
 setDBSlaveHost ($a_host)
 Set slave database host.
 getDBSlaveHost ()
 Get slave database host.
 setDBSlavePassword ($a_password)
 Set slave database password.
 getDBSlavePassword ()
 Get slave database password.
 setDBSlaveName ($a_name)
 Set slave database name.
 getDBSlaveName ()
 Get slave database name.
 getDSN ()
 Get DSN.
 getSlaveDSN ()
 Get slave DSN.
 getHostDSN ()
 Get Host DSN.
 getDBType ()
 Get DB Type.
 setStorageEngine ($a_storage_engine)
 Set the storage engine.
 initFromIniFile ($tmpClientIniFile=null)
 Init db parameters from ini file.
 doConnect ()
 Standard way to connect to db.
 initConnection ()
 Initialize the database connection.
 now ()
 now()
 optimizeTable ($a_table)
 Optimize Table.
 getDBVersion ()
 get mysql version
 isMysql4_0OrHigher ()
 check wether current MySQL server is version 4.0.x or higher
 isMysql4_1 ()
 check wether current MySQL server is version 4.1.x
 isMysql4_1OrHigher ()
 check wether current MySQL server is version 4.1.x or higher
 isMysql5_6OrHigher ()
 check wether current MySQL server is version 5.6.x or higher
 checkQuerySize ($a_query)
 Check query size.
 supportsFulltext ()
 Is fulltext index supported?
 addFulltextIndex ($a_table, $a_fields, $a_name="in")
 Add fulltext index.
 dropFulltextIndex ($a_table, $a_name)
 Add fulltext index.
 isFulltextIndex ($a_table, $a_name)
 Is index a fulltext index?
 lockTables ($a_tables)
 Lock table.
 unlockTables ()
 Unlock tables.
 getErrorNo ()
 getLastError ()
 query ($sql, $a_handle_error=true)
 Query.
- Public Member Functions inherited from ilDB
 ilDB ()
 constructor
 setDBUser ($a_user)
 Set database user.
 getDBUser ()
 Get database user.
 setDBPort ($a_port)
 Set database port.
 getDBPort ()
 Get database port.
 setDBHost ($a_host)
 Set database host.
 getDBHost ()
 Get database host.
 setDBPassword ($a_password)
 Set database password.
 getDBPassword ()
 Get database password.
 setDBName ($a_name)
 Set database name.
 getDBName ()
 Get database name.
 enableResultBuffering ($a_status)
 En/disable result buffering.
 connect ($a_return_false_for_error=false)
 Open the connection.
 disconnect ()
 Disconnect.
 connectHost ()
 Sets up a host connection only (no specific database used).
 useSlave ($a_val=true)
 Use slave.
 handleError ($a_res, $a_info="", $a_level="")
 Handle MDB2 Errors.
 raisePearError ($a_message, $a_level="")
 Raise an error.
 createDatabase ($a_name, $a_charset="utf8", $a_collation="")
 Create database.
 createTable ($a_name, $a_definition_array, $a_drop_table=false, $a_ignore_erros=false)
 Create a new table in the database.
 dropTable ($a_name, $a_error_if_not_existing=true)
 Drop a table.
 alterTable ($a_name, $a_changes)
 Alter a table in the database This method is DEPRECATED, see http://www.ilias.de/docu/goto.php?target=pg_25354_42&client_id=docu PLEASE USE THE SPECIALIZED METHODS OF THIS CLASS TO CHANGE THE DB SCHEMA.
 addTableColumn ($a_table, $a_column, $a_attributes)
 Add table column Use this only on aleady "abstracted" tables.
 dropTableColumn ($a_table, $a_column)
 Drop table column Use this only on aleady "abstracted" tables.
 modifyTableColumn ($a_table, $a_column, $a_attributes)
 Modify a table column Use this only on aleady "abstracted" tables.
 renameTableColumn ($a_table, $a_column, $a_new_column)
 Rename a table column Use this only on aleady "abstracted" tables.
 renameTable ($a_name, $a_new_name)
 Rename a table.
 addPrimaryKey ($a_table, $a_fields)
 Add a primary key to a table.
 getPrimaryKeyIdentifier ()
 Primary key identifier.
 dropPrimaryKey ($a_table)
 Drop a primary key from a table.
 addIndex ($a_table, $a_fields, $a_name="in", $a_fulltext=false)
 Add an index to a table.
 indexExistsByFields ($a_table, $a_fields)
 Check if index exists.
 dropIndexByFields ($a_table, $a_fields)
 Drop index by field(s)
 dropIndex ($a_table, $a_name="in")
 Drop an index from a table.
 addUniqueConstraint ($a_table, $a_fields, $a_name="con")
 Add a unique constraint to a table.
 createSequence ($a_table_name, $a_start=1)
 Create a sequence for a table.
 dropSequence ($a_table_name)
 Drop a sequence for a table.
 checkTableName ($a_name)
 Check whether a table name is valid.
 checkTableColumns ($a_cols)
 Check table columns definition.
 checkColumn ($a_col, $a_def)
 Check column definition.
 checkColumnDefinition ($a_def, $a_modify_mode=false)
 Check whether a column definition is valid.
 checkColumnName ($a_name)
 Check whether a column name is valid.
 checkIndexName ($a_name)
 Check whether an index name is valid.
 getAllowedAttributes ()
 constraintName ($a_table, $a_constraint)
 Determine contraint name by table name and constraint name.
 queryF ($a_query, $a_types, $a_values)
 Formatted query (for SELECTS).
 manipulateF ($a_query, $a_types, $a_values)
 Formatted manupulate (for DELETE, UPDATE, INSERT).
 logStatement ($sql)
 Helper function, should usually not be called.
 setLimit ($a_limit, $a_offset=0)
 Set limit and offset for a query.
 nextId ($a_table_name)
 Get next ID for an index.
 manipulate ($sql)
 Data manipulation.
 prepare ($a_query, $a_types=null, $a_result_types=null)
 Prepare a query (SELECT) statement to be used with execute.
 prepareManip ($a_query, $a_types=null)
 Prepare a data manipulation statement to be used with execute.
 execute ($a_stmt, $a_data=null)
 Execute a query statement prepared by either prepare() or prepareManip()
 executeMultiple ($a_stmt, $a_data)
 Execute a query statement prepared by either prepare() or prepareManip() with multiple data arrays.
 insert ($a_table, $a_columns)
 Convenient method for standard insert statements, example field array:
 update ($a_table, $a_columns, $a_where)
 Convenient method for standard update statements, example field array:
 replace ($a_table, $a_pk_columns, $a_other_columns)
 Replace into method.
 fetchAssoc ($a_set)
 Fetch row as associative array from result set.
 free ($a_st)
 Free a statement / result set.
 fetchObject ($a_set)
 Fetch row as object from result set.
 numRows ($a_set)
 Fetch row as associative array from result set.
 in ($a_field, $a_values, $negate=false, $a_type="")
 Get abstract in-clause for given array.
 addTypesToArray ($a_arr, $a_type, $a_cnt)
 Adds a type x times to an array.
 concat ($a_values, $a_allow_null=true)
 Abstraction of SQL function CONCAT.
 substr ($a_exp, $a_pos=1, $a_len=-1)
 Substring.
 upper ($a_exp)
 Upper.
 lower ($a_exp)
 Upper.
 locate ($a_needle, $a_string, $a_start_pos=1)
 Create locate string.
 like ($a_col, $a_type, $a_value="?", $case_insensitive=true)
 Like.
 equals ($a_col, $a_value, $a_type, $a_empty_or_null=false)
 Use this only on text fields.
 equalsNot ($a_col, $a_value, $a_type, $a_empty_or_null=false)
 Use this only on text fields.
 fromUnixtime ($a_expr, $a_to_text=true)
 fromUnixtime (makes timestamp out of unix timestamp)
 unixTimestamp ()
 Unix timestamp.
 tableExists ($a_table)
 Check, whether a given table exists.
 tableColumnExists ($a_table, $a_column_name)
 Checks for the existence of a table column.
 uniqueConstraintExists ($a_table, $a_fields)
 Checks if a unique constraint exists based on the fields of the unique constraint (not the name)
 listTables ()
 Get all tables.
 sequenceExists ($a_sequence)
 Check, whether a given sequence exists.
 listSequences ()
 Get all sequences.
 quote ($a_query, $a_type=null)
 Wrapper for quote method.
 quoteIdentifier ($a_identifier)
 Quote table and field names.
 beginTransaction ()
 Begin Transaction.
 commit ()
 Commit a transaction.
 rollback ()
 Rollback a transaction.
 autoExecute ($a_tablename, $a_fields, $a_mode=MDB2_AUTOQUERY_INSERT, $a_where=false)
 Wrapper for Pear autoExecute.
 getLastInsertId ()
 Get last insert id.
 getOne ($sql)
 getOne.
 getRow ($sql, $mode=DB_FETCHMODE_OBJECT)
 getRow.
 setSubType ($a_value)
 Set sub type.
 getSubType ()
 Get sub type.
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Static Public Member Functions

static getReservedWords ()
 Get reserved words.
- Static Public Member Functions inherited from ilDB
static isDbError ($a_res)
 Check error.
static isReservedWord ($a_word)
 Checks whether a word is a reserved word in one of the supported databases.

Data Fields

 $max_allowed_packet_size
- Data Fields inherited from ilDB
const LOCK_WRITE = 1
const LOCK_READ = 2
 $error_class
 $db
 $result
 $allowed_attributes
 $sub_type
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Protected Member Functions

 __buildDSN ($a_host, $a_name, $a_user, $a_pass, $a_port="")
 Build DSN string.
 isMySQLi ()
 setMaxAllowedPacket ()
 Set maximum allowed packet size.
 getCreateTableOptions ()
 Get options for the create table statement.
- Protected Member Functions inherited from ilDB
 initHostConnection ()
 Initialize the host connection (no specific database)
 loadMDB2Extensions ()
 load additional mdb2 extensions and set their constants

Protected Attributes

 $slave_active = false
 $use_slave = false

Detailed Description

MySQL Database Wrapper.

This class extends the main ILIAS database wrapper ilDB. Only a few methods should be overwritten, that contain MySQL specific statements and methods.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilDB.php 18989 2009-02-15 12:57:19Z akill

Definition at line 18 of file class.ilDBMySQL.php.

Member Function Documentation

ilDBMySQL::__buildDSN (   $a_host,
  $a_name,
  $a_user,
  $a_pass,
  $a_port = "" 
)
protected

Build DSN string.

Parameters
@return

Definition at line 183 of file class.ilDBMySQL.php.

References isMySQLi().

Referenced by getDSN(), and getSlaveDSN().

{
$db_port_str = "";
if (trim($a_port) != "")
{
$db_port_str = ":".$a_port;
}
$driver = $this->isMySQLi() ? "mysqli" : "mysql";
return $driver."://".$a_user.":".$a_pass.
"@".$a_host.$db_port_str."/".$a_name;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::addFulltextIndex (   $a_table,
  $a_fields,
  $a_name = "in" 
)

Add fulltext index.

Reimplemented from ilDB.

Definition at line 505 of file class.ilDBMySQL.php.

References ilDB\constraintName(), and query().

{
$i_name = $this->constraintName($a_table, $a_name)."_idx";
$f_str = implode($a_fields, ",");
$q = "ALTER TABLE $a_table ADD FULLTEXT $i_name ($f_str)";
$this->query($q);
}

+ Here is the call graph for this function:

ilDBMySQL::checkQuerySize (   $a_query)

Check query size.

Definition at line 448 of file class.ilDBMySQL.php.

References $lang.

{
global $lang;
if(strlen($a_query) >= $this->max_allowed_packet_size)
{
return false;
}
else
{
return true;
}
}
ilDBMySQL::doConnect ( )

Standard way to connect to db.

Reimplemented from ilDB.

Definition at line 311 of file class.ilDBMySQL.php.

References ilDB\connect(), getDBSlaveActive(), and getSlaveDSN().

{
if ($this->getDBSlaveActive())
{
$this->slave = MDB2::connect($this->getSlaveDSN(),
array("use_transactions" => false));
}
}

+ Here is the call graph for this function:

ilDBMySQL::dropFulltextIndex (   $a_table,
  $a_name 
)

Add fulltext index.

Definition at line 516 of file class.ilDBMySQL.php.

References ilDB\constraintName(), and query().

{
$i_name = $this->constraintName($a_table, $a_name)."_idx";
$this->query("ALTER TABLE $a_table DROP FULLTEXT $i_name");
}

+ Here is the call graph for this function:

ilDBMySQL::getCreateTableOptions ( )
protected

Get options for the create table statement.

Returns
array

Reimplemented from ilDB.

Reimplemented in ilDBInnoDB.

Definition at line 600 of file class.ilDBMySQL.php.

{
// InnoDB is default engine for MySQL >= 5.5
return array('type' => 'MyISAM');
}
ilDBMySQL::getDBSlaveActive ( )

Get slave active.

Returns
bool slave active

Definition at line 54 of file class.ilDBMySQL.php.

References $slave_active.

Referenced by doConnect(), and query().

{
}

+ Here is the caller graph for this function:

ilDBMySQL::getDBSlaveHost ( )

Get slave database host.

Parameters
stringslave database host

Definition at line 114 of file class.ilDBMySQL.php.

Referenced by getSlaveDSN().

{
return $this->slave_host;
}

+ Here is the caller graph for this function:

ilDBMySQL::getDBSlaveName ( )

Get slave database name.

Parameters
stringslave database name

Definition at line 154 of file class.ilDBMySQL.php.

Referenced by getSlaveDSN().

{
return $this->slave_name;
}

+ Here is the caller graph for this function:

ilDBMySQL::getDBSlavePassword ( )

Get slave database password.

Parameters
stringslave database password

Definition at line 134 of file class.ilDBMySQL.php.

Referenced by getSlaveDSN().

{
return $this->slave_password;
}

+ Here is the caller graph for this function:

ilDBMySQL::getDBSlavePort ( )

Get slave database port.

Parameters
stringslave database port

Definition at line 94 of file class.ilDBMySQL.php.

Referenced by getSlaveDSN().

{
return $this->slave_port;
}

+ Here is the caller graph for this function:

ilDBMySQL::getDBSlaveUser ( )

Get slave database user.

Parameters
stringslave database user

Definition at line 74 of file class.ilDBMySQL.php.

Referenced by getSlaveDSN().

{
return $this->slave_user;
}

+ Here is the caller graph for this function:

ilDBMySQL::getDBType ( )

Get DB Type.

Reimplemented from ilDB.

Reimplemented in ilDBInnoDB.

Definition at line 216 of file class.ilDBMySQL.php.

{
return "mysql";
}
ilDBMySQL::getDBVersion ( )

get mysql version

Reimplemented from ilDB.

Definition at line 362 of file class.ilDBMySQL.php.

References isMySQLi().

Referenced by isMysql4_0OrHigher(), isMysql4_1(), isMysql4_1OrHigher(), isMysql5_6OrHigher(), and setMaxAllowedPacket().

{
if(!$this->isMySQLi())
{
$vers = @mysql_get_server_info();
}
else
{
$vers = @mysqli_get_server_info($this->db->connection);
}
if (trim($vers) == "")
{
$vers = "Unknown";
}
return $vers;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::getDSN ( )

Get DSN.

Reimplemented from ilDB.

Definition at line 162 of file class.ilDBMySQL.php.

References __buildDSN(), ilDB\getDBHost(), ilDB\getDBName(), ilDB\getDBPassword(), ilDB\getDBPort(), and ilDB\getDBUser().

{
return $this->__buildDSN($this->getDBHost(), $this->getDBName(),
$this->getDBUser(), $this->getDBPassword(), $this->getDBPort());
}

+ Here is the call graph for this function:

ilDBMySQL::getErrorNo ( )

Definition at line 606 of file class.ilDBMySQL.php.

References isMySQLi().

{
if(!$this->isMySQLi())
{
return mysql_errno();
}
else
{
return mysqli_errno($this->db->connection);
}
}

+ Here is the call graph for this function:

ilDBMySQL::getHostDSN ( )

Get Host DSN.

Reimplemented from ilDB.

Definition at line 205 of file class.ilDBMySQL.php.

References ilDB\getDBPassword(), ilDB\getDBUser(), and isMySQLi().

{
$driver = $this->isMySQLi() ? "mysqli" : "mysql";
return $driver."://".$this->getDBUser().":".$this->getDBPassword().
"@".$this->getdbHost();
}

+ Here is the call graph for this function:

ilDBMySQL::getLastError ( )

Definition at line 618 of file class.ilDBMySQL.php.

References isMySQLi().

{
if(!$this->isMySQLi())
{
return mysql_error();
}
else
{
return mysqli_error($this->db->connection);
}
}

+ Here is the call graph for this function:

static ilDBMySQL::getReservedWords ( )
static

Get reserved words.

Reimplemented from ilDB.

Definition at line 232 of file class.ilDBMySQL.php.

{
// version: 5.1
// url: http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
return array(
"ACCESSIBLE", "ADD", "ALL", "ALTER", "ANALYZE", "AND",
"AS", "ASC", "ASENSITIVE", "BEFORE", "BETWEEN", "BIGINT",
"BINARY", "BLOB", "BOTH", "BY", "CALL", "CASCADE",
"CASE", "CHANGE", "CHAR", "CHARACTER", "CHECK", "COLLATE",
"COLUMN", "CONDITION", "CONSTRAINT", "CONTINUE", "CONVERT", "CREATE",
"CROSS", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR",
"DATABASE", "DATABASES", "DAY_HOUR", "DAY_MICROSECOND", "DAY_MINUTE", "DAY_SECOND",
"DEC", "DECIMAL", "DECLARE", "DEFAULT", "DELAYED", "DELETE",
"DESC", "DESCRIBE", "DETERMINISTIC", "DISTINCT", "DISTINCTROW", "DIV",
"DOUBLE", "DROP", "DUAL", "EACH", "ELSE", "ELSEIF",
"ENCLOSED", "ESCAPED", "EXISTS", "EXIT", "EXPLAIN", "FALSE",
"FETCH", "FLOAT", "FLOAT4", "FLOAT8", "FOR", "FORCE",
"FOREIGN", "FROM", "FULLTEXT", "GRANT", "GROUP", "HAVING",
"HIGH_PRIORITY", "HOUR_MICROSECOND", "HOUR_MINUTE", "HOUR_SECOND", "IF", "IGNORE",
"IN", "INDEX", "INFILE", "INNER", "INOUT", "INSENSITIVE",
"INSERT", "INT", "INT1", "INT2", "INT3", "INT4",
"INT8", "INTEGER", "INTERVAL", "INTO", "IS", "ITERATE",
"JOIN", "KEY", "KEYS", "KILL", "LEADING", "LEAVE",
"LEFT", "LIKE", "LIMIT", "LINEAR", "LINES", "LOAD",
"LOCALTIME", "LOCALTIMESTAMP", "LOCK", "LONG", "LONGBLOB", "LONGTEXT",
"LOOP", "LOW_PRIORITY", "MASTER_SSL_VERIFY_SERVER_CERT", "MATCH", "MEDIUMBLOB", "MEDIUMINT",
"MEDIUMTEXT", "MIDDLEINT", "MINUTE_MICROSECOND", "MINUTE_SECOND", "MOD", "MODIFIES",
"NATURAL", "NOT", "NO_WRITE_TO_BINLOG", "NULL", "NUMERIC", "ON",
"OPTIMIZE", "OPTION", "OPTIONALLY", "OR", "ORDER", "OUT",
"OUTER", "OUTFILE", "PRECISION", "PRIMARY", "PROCEDURE", "PURGE",
"RANGE", "READ", "READS", "READ_WRITE", "REAL", "REFERENCES",
"REGEXP", "RELEASE", "RENAME", "REPEAT", "REPLACE", "REQUIRE",
"RESTRICT", "RETURN", "REVOKE", "RIGHT", "RLIKE", "SCHEMA",
"SCHEMAS", "SECOND_MICROSECOND", "SELECT", "SENSITIVE", "SEPARATOR", "SET",
"SHOW", "SMALLINT", "SPATIAL", "SPECIFIC", "SQL", "SQLEXCEPTION",
"SQLSTATE", "SQLWARNING", "SQL_BIG_RESULT", "SQL_CALC_FOUND_ROWS", "SQL_SMALL_RESULT", "SSL",
"STARTING", "STRAIGHT_JOIN", "TABLE", "TERMINATED", "THEN", "TINYBLOB",
"TINYINT", "TINYTEXT", "TO", "TRAILING", "TRIGGER", "TRUE",
"UNDO", "UNION", "UNIQUE", "UNLOCK", "UNSIGNED", "UPDATE",
"USAGE", "USE", "USING", "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP",
"VALUES", "VARBINARY", "VARCHAR", "VARCHARACTER", "VARYING", "WHEN",
"WHERE", "WHILE", "WITH", "WRITE", "XOR", "YEAR_MONTH",
"ZEROFILL"
);
}
ilDBMySQL::getSlaveDSN ( )

Get slave DSN.

Definition at line 171 of file class.ilDBMySQL.php.

References __buildDSN(), getDBSlaveHost(), getDBSlaveName(), getDBSlavePassword(), getDBSlavePort(), and getDBSlaveUser().

Referenced by doConnect().

{
return $this->__buildDSN($this->getDBSlaveHost(), $this->getDBSlaveName(),
$this->getDBSlaveUser(), $this->getDBSlavePassword(), $this->getDBSlavePort());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::initConnection ( )

Initialize the database connection.

Reimplemented from ilDB.

Reimplemented in ilDBInnoDB.

Definition at line 325 of file class.ilDBMySQL.php.

References query(), setMaxAllowedPacket(), and setStorageEngine().

{
// SET 'max_allowed_packet' (only possible for mysql version 4)
// NOTE: Two sourcecodes use this or a similar handling:
// - classes/class.ilDB.php
// - setup/classes/class.ilClient.php
$this->query("SET NAMES utf8");
if (DEVMODE == 1)
{
$this->query("SET SESSION SQL_MODE = 'ONLY_FULL_GROUP_BY'");
}
$this->setStorageEngine('MYISAM');
}

+ Here is the call graph for this function:

ilDBMySQL::initFromIniFile (   $tmpClientIniFile = null)

Init db parameters from ini file.

Parameters
$tmpClientIniFileoverwrite global client ini file if is set to an object

Reimplemented from ilDB.

Definition at line 282 of file class.ilDBMySQL.php.

References setDBSlaveActive(), setDBSlaveHost(), setDBSlaveName(), setDBSlavePassword(), setDBSlavePort(), and setDBSlaveUser().

{
global $ilClientIniFile;
parent::initFromIniFile($tmpClientIniFile);
//overwrite global client ini file if local parameter is set
if (is_object($tmpClientIniFile))
$clientIniFile = $tmpClientIniFile;
else
$clientIniFile = $ilClientIniFile;
if (is_object($clientIniFile ))
{
if ($clientIniFile->readVariable("db", "slave_active") == 1)
{
$this->setDBSlaveActive(true);
$this->setDBSlaveUser($clientIniFile->readVariable("db", "slave_user"));
$this->setDBSlaveHost($clientIniFile->readVariable("db", "slave_host"));
$this->setDBSlavePort($clientIniFile->readVariable("db", "slave_port"));
$this->setDBSlavePassword($clientIniFile->readVariable("db", "slave_pass"));
$this->setDBSlaveName($clientIniFile->readVariable("db", "slave_name"));
}
}
}

+ Here is the call graph for this function:

ilDBMySQL::isFulltextIndex (   $a_table,
  $a_name 
)

Is index a fulltext index?

Reimplemented from ilDB.

Definition at line 525 of file class.ilDBMySQL.php.

References ilDB\fetchAssoc(), and query().

{
$set = $this->query("SHOW INDEX FROM ".$a_table);
while ($rec = $this->fetchAssoc($set))
{
if ($rec["Key_name"] == $a_name && $rec["Index_type"] == "FULLTEXT")
{
return true;
}
}
}

+ Here is the call graph for this function:

ilDBMySQL::isMysql4_0OrHigher ( )

check wether current MySQL server is version 4.0.x or higher

Definition at line 383 of file class.ilDBMySQL.php.

References getDBVersion().

{
$version = explode(".", $this->getDBVersion());
if((int) $version[0] < 4)
{
return false;
}
return true;
}

+ Here is the call graph for this function:

ilDBMySQL::isMysql4_1 ( )

check wether current MySQL server is version 4.1.x

Definition at line 396 of file class.ilDBMySQL.php.

References getDBVersion().

{
$version = explode(".", $this->getDBVersion());
if ($version[0] == "4" && $version[1] == "1")
{
return true;
}
return false;
}

+ Here is the call graph for this function:

ilDBMySQL::isMysql4_1OrHigher ( )

check wether current MySQL server is version 4.1.x or higher

NOTE: Two sourcecodes use this or a similar handling:

Definition at line 414 of file class.ilDBMySQL.php.

References getDBVersion().

{
$version = explode(".", $this->getDBVersion());
if ((int)$version[0] >= 5 ||
((int)$version[0] == 4 && (int)$version[1] >= 1))
{
return true;
}
return false;
}

+ Here is the call graph for this function:

ilDBMySQL::isMysql5_6OrHigher ( )

check wether current MySQL server is version 5.6.x or higher

NOTE: Two sourcecodes use this or a similar handling:

Definition at line 433 of file class.ilDBMySQL.php.

References getDBVersion().

Referenced by setStorageEngine().

{
$version = explode(".", $this->getDBVersion());
if(
(int) $version[0] > 5 ||
((int) $version[0] == 5 && (int) $version[1] >= 6))
{
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::isMySQLi ( )
protected

Definition at line 197 of file class.ilDBMySQL.php.

References ilDB\getSubType().

Referenced by __buildDSN(), getDBVersion(), getErrorNo(), getHostDSN(), and getLastError().

{
return ($this->getSubType() == "mysqli");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::lockTables (   $a_tables)

Lock table.

E.g $ilDB->lockTable('tree',ilDB::LOCK_WRITE,'t1')

Parameters
array$a_tables
int$a_mode
string$a_alias
Returns

Reimplemented from ilDB.

Definition at line 546 of file class.ilDBMySQL.php.

References $ilLog, ilDB\LOCK_READ, ilDB\LOCK_WRITE, and query().

{
global $ilLog;
$lock = 'LOCK TABLES ';
$counter = 0;
foreach($a_tables as $table)
{
if($counter++)
{
$lock .= ', ';
}
if( isset($table['sequence']) && $table['sequence'] )
{
$tableName = $this->db->getSequenceName($table['name']);
}
else
{
$tableName = $table['name'];
}
$lock .= ($tableName.' ');
if($table['alias'])
{
$lock .= ($table['alias'].' ');
}
switch($table['type'])
{
$lock .= ' READ ';
break;
$lock .= ' WRITE ';
break;
}
}
$ilLog->write(__METHOD__.': '.$lock);
$this->query($lock);
}

+ Here is the call graph for this function:

ilDBMySQL::now ( )

now()

Reimplemented from ilDB.

Definition at line 346 of file class.ilDBMySQL.php.

{
return "now()";
}
ilDBMySQL::optimizeTable (   $a_table)

Optimize Table.

Reimplemented from ilDB.

Definition at line 354 of file class.ilDBMySQL.php.

References query().

{
$this->query("OPTIMIZE TABLE ".$a_table);
}

+ Here is the call graph for this function:

ilDBMySQL::query (   $sql,
  $a_handle_error = true 
)

Query.

Parameters
@return

Reimplemented from ilDB.

Definition at line 636 of file class.ilDBMySQL.php.

References getDBSlaveActive(), and ilDB\handleError().

Referenced by addFulltextIndex(), dropFulltextIndex(), ilDBInnoDB\initConnection(), initConnection(), isFulltextIndex(), lockTables(), optimizeTable(), setMaxAllowedPacket(), setStorageEngine(), and unlockTables().

{
if (!$this->use_slave || !$this->getDBSlaveActive())
{
return parent::query($sql, $a_handle_error);
}
$r = $this->slave->query($sql);
if ($a_handle_error)
{
return $this->handleError($r, "query(".$sql.")");
}
return $r;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::setDBSlaveActive (   $a_val)

Set slave active.

Parameters
bool$a_valslave active

Definition at line 44 of file class.ilDBMySQL.php.

Referenced by initFromIniFile().

{
$this->slave_active = $a_val;
}

+ Here is the caller graph for this function:

ilDBMySQL::setDBSlaveHost (   $a_host)

Set slave database host.

Parameters
stringslave database host

Definition at line 104 of file class.ilDBMySQL.php.

Referenced by initFromIniFile().

{
$this->slave_host = $a_host;
}

+ Here is the caller graph for this function:

ilDBMySQL::setDBSlaveName (   $a_name)

Set slave database name.

Parameters
stringslave database name

Definition at line 144 of file class.ilDBMySQL.php.

Referenced by initFromIniFile().

{
$this->slave_name = $a_name;
}

+ Here is the caller graph for this function:

ilDBMySQL::setDBSlavePassword (   $a_password)

Set slave database password.

Parameters
stringslave database password

Definition at line 124 of file class.ilDBMySQL.php.

Referenced by initFromIniFile().

{
$this->slave_password = $a_password;
}

+ Here is the caller graph for this function:

ilDBMySQL::setDBSlavePort (   $a_port)

Set slave database port.

Parameters
stringslave database port

Definition at line 84 of file class.ilDBMySQL.php.

Referenced by initFromIniFile().

{
$this->slave_port = $a_port;
}

+ Here is the caller graph for this function:

ilDBMySQL::setDBSlaveUser (   $a_user)

Set slave database user.

Parameters
stringslave database user

Definition at line 64 of file class.ilDBMySQL.php.

Referenced by initFromIniFile().

{
$this->slave_user = $a_user;
}

+ Here is the caller graph for this function:

ilDBMySQL::setMaxAllowedPacket ( )
protected

Set maximum allowed packet size.

todo@: This is MySQL specific and should go to a MySQL specific class.

Definition at line 467 of file class.ilDBMySQL.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, getDBVersion(), query(), and ilDB\substr().

Referenced by ilDBInnoDB\initConnection(), and initConnection().

{
$version = $this->getDBVersion();
// CHANG VALUE IF MYSQL VERSION > 4.0
// Switched back to "SET GLOBAL ..."
// @see http://bugs.mysql.com/bug.php?id=22891
// smeyer 2009 07 30
if (substr($version,0,1) == "4")
{
ini_get("post_max_size");
$query = "SET GLOBAL max_allowed_packet = ".(int) ini_get("post_max_size") * 1024 * 1024;
//echo "-".$query."-";
$this->query($query);
}
// STORE NEW max_size in member variable
$query = "SHOW VARIABLES LIKE 'max_allowed_packet'";
$res = $this->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->max_allowed_packet_size = $row->value;
}
//echo "-".$this->max_allowed_packet_size."-";
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::setStorageEngine (   $a_storage_engine)

Set the storage engine.

Definition at line 224 of file class.ilDBMySQL.php.

References isMysql5_6OrHigher(), and query().

Referenced by ilDBInnoDB\initConnection(), and initConnection().

{
$storage_engine_var = ($this->isMysql5_6OrHigher()) ? "DEFAULT_STORAGE_ENGINE" : "STORAGE_ENGINE";
$this->query("SET SESSION " . $storage_engine_var . " = '" . $a_storage_engine . "'");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDBMySQL::supportsFulltext ( )

Is fulltext index supported?

Reimplemented from ilDB.

Reimplemented in ilDBInnoDB.

Definition at line 497 of file class.ilDBMySQL.php.

{
return true;
}
ilDBMySQL::supportsSlave ( )

Supports slave.

Parameters
@return

Reimplemented from ilDB.

Definition at line 34 of file class.ilDBMySQL.php.

{
return true;
}
ilDBMySQL::unlockTables ( )

Unlock tables.

Returns

Reimplemented from ilDB.

Definition at line 595 of file class.ilDBMySQL.php.

References query().

{
$this->query('UNLOCK TABLES');
}

+ Here is the call graph for this function:

Field Documentation

ilDBMySQL::$max_allowed_packet_size

Definition at line 24 of file class.ilDBMySQL.php.

ilDBMySQL::$slave_active = false
protected

Definition at line 25 of file class.ilDBMySQL.php.

Referenced by getDBSlaveActive().

ilDBMySQL::$use_slave = false
protected

Definition at line 26 of file class.ilDBMySQL.php.


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