8 include_once (
"MDB2.php");
 
   55                         "text" => array(
"length", 
"notnull", 
"default", 
"fixed"),
 
   56                         "integer" => array(
"length", 
"notnull", 
"default", 
"unsigned"),
 
   57                         "float" => array(
"notnull", 
"default"),
 
   58                         "date" => array(
"notnull", 
"default"),
 
   59                         "time" => array(
"notnull", 
"default"),
 
   60                         "timestamp" => array(
"notnull", 
"default"),
 
   61                         "clob" => array(
"notnull", 
"default"),
 
   62                         "blob" => array(
"notnull", 
"default")
 
   85                 $this->db_user = $a_user;
 
  105                 $this->db_port = $a_port;
 
  115                 return $this->db_port;
 
  125                 $this->db_host = $a_host;
 
  145                 $this->db_password = $a_password;
 
  155                 return $this->db_password;
 
  165                 $this->db_name = $a_name;
 
  181         abstract function getDSN();
 
  211                 $this->db->setOption(
'result_buffering',$a_status);
 
  220                 global $ilClientIniFile;
 
  223                 if (is_object($tmpClientIniFile))
 
  224                         $clientIniFile = $tmpClientIniFile;
 
  226                         $clientIniFile = $ilClientIniFile;      
 
  228                 if (is_object($clientIniFile ))
 
  230                         $this->
setDBUser($clientIniFile ->readVariable(
"db", 
"user"));
 
  231                         $this->
setDBHost($clientIniFile ->readVariable(
"db", 
"host"));
 
  232                         $this->
setDBPort($clientIniFile ->readVariable(
"db", 
"port"));
 
  233                         $this->
setDBPassword($clientIniFile ->readVariable(
"db", 
"pass"));
 
  234                         $this->
setDBName($clientIniFile ->readVariable(
"db", 
"name"));
 
  241         function connect($a_return_false_for_error = 
false)
 
  248                 if ($this->
getDSN() == 
"")
 
  283                         array(
"use_transactions" => 
true));
 
  291                 $this->db->disconnect();
 
  334                         array(
"use_transactions" => 
true));
 
  346                         $this->db->setOption(
"portability", $this->db->getOption(
"portability") - $cur);
 
  349                         $this->db->setOption(
"portability", $this->db->getOption(
"portability") - $cur);
 
  387                                 $a_level = $this->error_class->FATAL;
 
  397                                 $stack = $e->getTraceAsString();
 
  400                         if(is_object($ilLog))
 
  403                                 $a_res->getMessage().
"<br />".$a_res->getUserInfo().
"<br />".$stack, $a_level);
 
  417                         $a_level = $this->error_class->FATAL;
 
  432                         $this->db->loadModule(
'Extended');
 
  457                 if ($a_collation != 
"")
 
  459                         $sql = 
"CREATE DATABASE ".$a_name.
 
  460                                 " CHARACTER SET ".$a_charset.
 
  461                                 " COLLATE ".$a_collation;
 
  465                         $sql = 
"CREATE DATABASE ".$a_name.
 
  466                                 " CHARACTER SET ".$a_charset;
 
  469                 return $this->
query($sql, 
false);
 
  480         function createTable($a_name, $a_definition_array, $a_drop_table = 
false,
 
  481                 $a_ignore_erros = 
false)
 
  486                         $this->
raisePearError(
"ilDB Error: createTable(".$a_name.
")<br />".
 
  493                         $this->
raisePearError(
"ilDB Error: createTable(".$a_name.
")<br />".
 
  504                 $manager = $this->db->loadModule(
'Manager');
 
  505                 $r = $manager->createTable($a_name, $a_definition_array, $options);
 
  507                 return $this->
handleError($r, 
"createTable(".$a_name.
")");
 
  526         function dropTable($a_name, $a_error_if_not_existing = 
true)
 
  528                 if (!$a_error_if_not_existing)
 
  531                         if (!in_array($a_name, $tables))
 
  537                 $manager = $this->db->loadModule(
'Manager');
 
  542                         $constraints = $manager->listTableConstraints($a_name);
 
  543                         $this->
handleError($constraints, 
"dropTable(".$a_name.
"), listTableConstraints");
 
  544                         foreach ($constraints as $c)
 
  546                                 if (
substr($c, 0, 4) != 
"sys_")
 
  548                                         $r = $manager->dropConstraint($a_name, $c);
 
  549                                         $this->
handleError($r, 
"dropTable(".$a_name.
"), dropConstraint");
 
  554                         $indexes = $manager->listTableIndexes($a_name);
 
  555                         $this->
handleError($indexes, 
"dropTable(".$a_name.
"), listTableIndexes");
 
  556                         foreach ($indexes as $i)
 
  558                                 $r = $manager->dropIndex($a_name, $i);
 
  559                                 $this->
handleError($r, 
"dropTable(".$a_name.
"), dropIndex");
 
  564                 $seqs = $manager->listSequences();
 
  565                 if (in_array($a_name, $seqs))
 
  567                         $r = $manager->dropSequence($a_name);
 
  568                         $this->
handleError($r, 
"dropTable(".$a_name.
"), dropSequence");
 
  572                 $r = $manager->dropTable($a_name);
 
  574                 return $this->
handleError($r, 
"dropTable(".$a_name.
")");
 
  584                 if ($a_options == 
"")
 
  586                         $a_options = array();
 
  589                 $manager = $this->db->loadModule(
'Manager');
 
  590                 $r = $manager->alterTable($a_name, $a_changes, 
false);
 
  592                 return $this->
handleError($r, 
"alterTable(".$a_name.
")");
 
  606                 $manager = $this->db->loadModule(
'Manager');
 
  610                         $this->
raisePearError(
"ilDB Error: addTableColumn(".$a_table.
", ".$a_column.
")<br />".
 
  615                         $this->
raisePearError(
"ilDB Error: addTableColumn(".$a_table.
", ".$a_column.
")<br />".
 
  621                                 $a_column => $a_attributes
 
  625                 $r = $manager->alterTable($a_table, $changes, 
false);
 
  627                 return $this->
handleError($r, 
"addTableColumn(".$a_table.
", ".$a_column.
")");
 
  640                 $manager = $this->db->loadModule(
'Manager');
 
  648                 $r = $manager->alterTable($a_table, $changes, 
false);
 
  650                 return $this->
handleError($r, 
"dropTableColumn(".$a_table.
", ".$a_column.
")");
 
  663                 $manager = $this->db->loadModule(
'Manager');
 
  664                 $reverse = $this->db->loadModule(
'Reverse');
 
  665                 $def = $reverse->getTableFieldDefinition($a_table, $a_column);
 
  667                 $this->
handleError($def, 
"modifyTableColumn(".$a_table.
")");
 
  669                 if (is_file(
"./Services/Database/classes/class.ilDBAnalyzer.php"))
 
  671                         include_once(
"./Services/Database/classes/class.ilDBAnalyzer.php");
 
  675                         include_once(
"../Services/Database/classes/class.ilDBAnalyzer.php");
 
  678                 $best_alt = $analyzer->getBestDefinitionAlternative($def);
 
  679                 $def = $def[$best_alt];
 
  680                 unset($def[
"nativetype"]);
 
  681                 unset($def[
"mdb2type"]);
 
  684                 $type = ($a_attributes[
"type"] != 
"")
 
  685                         ? $a_attributes[
"type"]
 
  687                 foreach ($def as $k => $v)
 
  689                         if ($k != 
"type" && !in_array($k, $this->allowed_attributes[$type]))
 
  695                 foreach ($a_attributes as $k => $v)
 
  697                         $check_array[$k] = $v;
 
  701                         $this->
raisePearError(
"ilDB Error: modifyTableColumn(".$a_table.
", ".$a_column.
")<br />".
 
  706                 if ($this->getDbType() == 
"oracle")
 
  708                         if ($def[
"notnull"] == 
true && ($a_attributes[
"notnull"] == 
true 
  709                                 || !isset($a_attributes[
"notnull"])))
 
  711                                 unset($def[
"notnull"]);
 
  712                                 unset($a_attributes[
"notnull"]);
 
  714                         if ($def[
"notnull"] == 
false && ($a_attributes[
"notnull"] == 
false 
  715                                 || !isset($a_attributes[
"notnull"])))
 
  717                                 unset($def[
"notnull"]);
 
  718                                 unset($a_attributes[
"notnull"]);
 
  721                 foreach ($a_attributes as $a => $v)
 
  726                 $a_attributes[
"definition"] = $def;
 
  730                                 $a_column => $a_attributes
 
  734                 $r = $manager->alterTable($a_table, $changes, 
false);
 
  736                 return $this->
handleError($r, 
"modifyTableColumn(".$a_table.
")");
 
  752                         $this->
raisePearError(
"ilDB Error: renameTableColumn(".$a_table.
",".$a_column.
",".$a_new_column.
")<br />".
 
  756                 $manager = $this->db->loadModule(
'Manager');
 
  757                 $reverse = $this->db->loadModule(
'Reverse');
 
  758                 $def = $reverse->getTableFieldDefinition($a_table, $a_column);
 
  760                 $this->
handleError($def, 
"renameTableColumn(".$a_table.
",".$a_column.
",".$a_new_column.
")");
 
  762                 if (is_file(
"./Services/Database/classes/class.ilDBAnalyzer.php"))
 
  764                         include_once(
"./Services/Database/classes/class.ilDBAnalyzer.php");
 
  768                         include_once(
"../Services/Database/classes/class.ilDBAnalyzer.php");
 
  772                 $best_alt = $analyzer->getBestDefinitionAlternative($def);
 
  773                 $def = $def[$best_alt];
 
  774                 unset($def[
"nativetype"]);
 
  775                 unset($def[
"mdb2type"]);
 
  777                 $f[
"definition"] = $def;
 
  778                 $f[
"name"] = $a_new_column;
 
  786                 $r = $manager->alterTable($a_table, $changes, 
false);
 
  788                 return $this->
handleError($r, 
"renameTableColumn(".$a_table.
",".$a_column.
",".$a_new_column.
")");
 
  802                         $this->
raisePearError(
"ilDB Error: renameTable(".$a_name.
",".$a_new_name.
")<br />".
 
  806                 $manager = $this->db->loadModule(
'Manager');
 
  807                 $r = $manager->alterTable($a_name, array(
"name" => $a_new_name), 
false);
 
  809                 $query = 
"UPDATE abstraction_progress ".
 
  810                         "SET table_name = ".$this->db->quote($a_new_name,
'text').
" ".
 
  811                         "WHERE table_name = ".$this->db->quote($a_name,
'text');
 
  814                 return $this->
handleError($r, 
"renameTable(".$a_name.
",".$a_new_name.
")");
 
  826                 $manager = $this->db->loadModule(
'Manager');
 
  829                 foreach ($a_fields as $f)
 
  831                         $fields[$f] = array();
 
  833                 $definition = array (
 
  837                 $r = $manager->createConstraint($a_table,
 
  840                 return $this->
handleError($r, 
"addPrimaryKey(".$a_table.
")");
 
  859                 $manager = $this->db->loadModule(
'Manager');
 
  861                 $r = $manager->dropConstraint($a_table,
 
  864                 return $this->
handleError($r, 
"dropPrimaryKey(".$a_table.
")");
 
  874         function addIndex($a_table, $a_fields, $a_name = 
"in", $a_fulltext = 
false)
 
  876                 $manager = $this->db->loadModule(
'Manager');
 
  881                         $this->
raisePearError(
"ilDB Error: addIndex(".$a_table.
",".$a_name.
")<br />".
 
  886                 foreach ($a_fields as $f)
 
  888                         $fields[$f] = array();
 
  890                 $definition = array (
 
  896                         $r = $manager->createIndex($a_table, $this->
constraintName($a_table, $a_name), $definition);
 
  906                 return $this->
handleError($r, 
"addIndex(".$a_table.
")");
 
  934                 $manager = $this->db->loadModule(
'Manager');
 
  938                         $r = $manager->dropIndex($a_table, $this->
constraintName($a_table, $a_name));
 
  942                         $this->dropFulltextIndex($a_table, $a_name);
 
  945                 return $this->
handleError($r, 
"dropIndex(".$a_table.
")");
 
  957                 $manager = $this->db->loadModule(
'Manager');
 
  962                         $this->
raisePearError(
"ilDB Error: addUniqueConstraint(".$a_table.
",".$a_name.
")<br />".
 
  967                 foreach ($a_fields as $f)
 
  969                         $fields[$f] = array();
 
  971                 $definition = array (
 
  976                 $r = $manager->createConstraint($a_table, $this->
constraintName($a_table, $a_name), $definition);
 
  978                 return $this->
handleError($r, 
"addUniqueConstraint(".$a_table.
")");
 
  986                 $manager = $this->db->loadModule(
'Manager');
 
  988                 $r = $manager->createSequence($a_table_name, $a_start);
 
  990                 return $this->
handleError($r, 
"createSequence(".$a_table_name.
")");
 
  999                 $manager = $this->db->loadModule(
'Manager');
 
 1001                 $r = $manager->dropSequence($a_table_name);
 
 1003                 return $this->
handleError($r, 
"dropSequence(".$a_table_name.
")");
 
 1013                 if (!preg_match (
"/^[a-z]+[_a-z0-9]*$/", $a_name))
 
 1015                         $this->error_str = 
"Table name must only contain _a-z0-9 and must start with a-z.";
 
 1021                         $this->error_str = 
"Invalid table name '".$a_name.
"' (Reserved Word).";
 
 1025                 if (strtolower(
substr($a_name, 0, 4)) == 
"sys_")
 
 1027                         $this->error_str = 
"Invalid table name '".$a_name.
"'. Name must not start with 'sys_'.";
 
 1031                 if (strlen($a_name) > 22)
 
 1033                         $this->error_str = 
"Invalid table name '".$a_name.
"'. Maximum table identifer lenght is 22 bytes.";
 
 1047                 foreach ($a_cols as $col => $def)
 
 1084                 if (!in_array($a_def[
"type"], array(
"text", 
"integer", 
"float", 
"date", 
"time", 
"timestamp", 
"clob", 
"blob")))
 
 1086                         switch ($a_def[
"type"])
 
 1089                                         $this->error_str = 
"Invalid column type '".$a_def[
"type"].
"'. Use integer(1) instead.";
 
 1093                                         $this->error_str = 
"Invalid column type '".$a_def[
"type"].
"'. Use float or integer instead.";
 
 1097                                         $this->error_str = 
"Invalid column type '".$a_def[
"type"].
"'. Allowed types are: ".
 
 1098                                                 "text, integer, float, date, time, timestamp, clob and blob.";
 
 1105                 foreach ($a_def as $k => $v)
 
 1109                                 $this->error_str = 
"Attribute '".$k.
"' is not allowed for column type '".$a_def[
"type"].
"'.";
 
 1115                 switch ($a_def[
"type"])
 
 1118                                 if ($a_def[
"length"] < 1 || $a_def[
"length"] > 4000)
 
 1120                                         if (!$a_modify_mode || isset($a_def[
"length"]))
 
 1122                                                 $this->error_str = 
"Invalid length '".$a_def[
"length"].
"' for type text.".
 
 1123                                                         " Length must be >=1 and <= 4000.";
 
 1130                                 if (!in_array($a_def[
"length"], array(1, 2, 3, 4, 8)))
 
 1132                                         if (!$a_modify_mode || isset($a_def[
"length"]))
 
 1134                                                 $this->error_str = 
"Invalid length '".$a_def[
"length"].
"' for type integer.".
 
 1135                                                         " Length must be 1, 2, 3, 4 or 8 (bytes).";
 
 1139                                 if ($a_def[
"unsigned"])
 
 1141                                         $this->error_str = 
"Unsigned attribut must not be true for type integer.";
 
 1157                 if (!preg_match (
"/^[a-z]+[_a-z0-9]*$/", $a_name))
 
 1159                         $this->error_str = 
"Invalid column name '".$a_name.
"'. Column name must only contain _a-z0-9 and must start with a-z.";
 
 1165                         $this->error_str = 
"Invalid column name '".$a_name.
"' (Reserved Word).";
 
 1169                 if (strtolower(
substr($a_name, 0, 4)) == 
"sys_")
 
 1171                         $this->error_str = 
"Invalid column name '".$a_name.
"'. Name must not start with 'sys_'.";
 
 1175                 if (strlen($a_name) > 30)
 
 1177                         $this->error_str = 
"Invalid column name '".$a_name.
"'. Maximum column identifer lenght is 30 bytes.";
 
 1191                 if (!preg_match (
"/^[a-z]+[_a-z0-9]*$/", $a_name))
 
 1193                         $this->error_str = 
"Invalid column name '".$a_name.
"'. Column name must only contain _a-z0-9 and must start with a-z.";
 
 1199                         $this->error_str = 
"Invalid column name '".$a_name.
"' (Reserved Word).";
 
 1203                 if (strlen($a_name) > 3)
 
 1205                         $this->error_str = 
"Invalid index name '".$a_name.
"'. Maximum index identifer lenght is 3 bytes.";
 
 1224                 return $a_constraint;
 
 1233                 include_once(
"./Services/Database/classes/class.ilDBMySQL.php");
 
 1235                 if (in_array(strtoupper($a_word), $mysql_reserved_words))
 
 1239                 include_once(
"./Services/Database/classes/class.ilDBOracle.php");
 
 1241                 if (in_array(strtoupper($a_word), $oracle_reserved_words))
 
 1245                 include_once(
"./Services/Database/classes/class.ilDBPostgreSQL.php");
 
 1247                 if (in_array(strtoupper($a_word), $postgres_reserved_words))
 
 1268         function query($sql, $a_handle_error = 
true)
 
 1272                 if (is_object($ilBench))
 
 1274                         $ilBench->startDbBench($sql);
 
 1276                 $r = $this->db->query($sql);
 
 1277                 if (is_object($ilBench))
 
 1279                         $ilBench->stopDbBench();
 
 1282                 if ($a_handle_error)
 
 1297         function queryF($a_query, $a_types, $a_values)
 
 1299                 if (!is_array($a_types) || !is_array($a_values) ||
 
 1300                         count($a_types) != count($a_values))
 
 1302                         $this->
raisePearError(
"ilDB::queryF: Types and values must be arrays of same size. ($a_query)");
 
 1304                 $quoted_values = array();
 
 1305                 foreach($a_types as $k => 
$t)
 
 1307                         $quoted_values[] = $this->
quote($a_values[$k], 
$t);
 
 1309                 $query = vsprintf($a_query, $quoted_values);
 
 1323                 if (!is_array($a_types) || !is_array($a_values) ||
 
 1324                         count($a_types) != count($a_values))
 
 1326                         $this->
raisePearError(
"ilDB::manipulateF: types and values must be arrays of same size. ($a_query)");
 
 1328                 $quoted_values = array();
 
 1329                 foreach($a_types as $k => 
$t)
 
 1331                         $quoted_values[] = $this->
quote($a_values[$k], 
$t);
 
 1333                 $query = vsprintf($a_query, $quoted_values);
 
 1343                 $pos1 = strpos(strtolower($sql), 
"from ");
 
 1347                         $tablef = 
substr($sql, $pos1+5);
 
 1348                         $pos2 = strpos(strtolower($tablef), 
" ");
 
 1351                                 $table =
substr($tablef, 0, $pos2);
 
 1358                 if (trim($table) != 
"")
 
 1360                         if (!is_array($this->ttt) || !in_array($table, $this->ttt))
 
 1363                                 $this->ttt[] = $table;
 
 1368                         echo 
"<br><b>".$sql.
"</b>";
 
 1377                 $this->db->setLimit($a_limit, $a_offset);
 
 1388                 $r = $this->db->nextId($a_table_name, 
false);
 
 1390                 return $this->
handleError($r, 
"nextId(".$a_table_name.
")");
 
 1407                 if (is_object($ilBench))
 
 1409                         $ilBench->startDbBench($sql);
 
 1411                 $r = $this->db->exec($sql);
 
 1412                 if (is_object($ilBench))
 
 1414                         $ilBench->stopDbBench();
 
 1417                 return $this->
handleError($r, 
"manipulate(".$sql.
")");
 
 1428         function prepare($a_query, $a_types = null, $a_result_types = null)
 
 1430                 $res = $this->db->prepare($a_query, $a_types, $a_result_types);
 
 1460                 $res = $a_stmt->execute($a_data);
 
 1476                 $res = $this->db->extended->executeMultiple($a_stmt,$a_data);
 
 1478                 return $this->
handleError(
$res, 
"executeMultiple(".$a_stmt->query.
")");
 
 1490                 $field_values = array();
 
 1491                 $placeholders = array();
 
 1496                 foreach ($a_columns as $k => $col)
 
 1499                         $placeholders[] = 
"%s";
 
 1500                         $placeholders2[] = 
":$k";
 
 1504                         if ($col[0] == 
'integer' && !is_null($col[1]))
 
 1506                                 $col[1] = (int) $col[1];
 
 1509                         $values[] = $col[1];
 
 1510                         $field_values[$k] = $col[1];
 
 1511                         if ($col[0] == 
"blob" || $col[0] == 
"clob")
 
 1519                         $st = $this->db->prepare(
"INSERT INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
 
 1522                         $this->
handleError($st, 
"insert / prepare/execute(".$a_table.
")");
 
 1524                         $r = $st->execute($field_values);
 
 1528                         $this->
handleError($r, 
"insert / prepare/execute(".$a_table.
")");
 
 1533                         $q = 
"INSERT INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
 
 1534                                 implode($placeholders,
",").
")";
 
 1548         function update($a_table, $a_columns, $a_where)
 
 1551                 $field_values = array();
 
 1552                 $placeholders = array();
 
 1557                 foreach ($a_columns as $k => $col)
 
 1560                         $placeholders[] = 
"%s";
 
 1561                         $placeholders2[] = 
":$k";
 
 1565                         if ($col[0] == 
'integer' && !is_null($col[1]))
 
 1567                                 $col[1] = (int) $col[1];
 
 1570                         $values[] = $col[1];
 
 1571                         $field_values[$k] = $col[1];
 
 1572                         if ($col[0] == 
"blob" || $col[0] == 
"clob")
 
 1581                         $q = 
"UPDATE ".$a_table.
" SET ";
 
 1583                         foreach ($fields as $k => $field)
 
 1585                                 $q.= $lim.$field.
" = ".$placeholders2[$k];
 
 1590                         foreach ($a_where as $k => $col)
 
 1592                                 $q.= $lim.$k.
" = ".$this->
quote($col[1], $col[0]);
 
 1596                         $r = $st->execute($field_values);
 
 1599                         $this->
handleError($r, 
"update / prepare/execute(".$a_table.
")");
 
 1604                         foreach ($a_where as $k => $col)
 
 1607                                 $values[] = $col[1];
 
 1608                                 $field_values[$k] = $col;
 
 1610                         $q = 
"UPDATE ".$a_table.
" SET ";
 
 1612                         foreach ($fields as $k => $field)
 
 1614                                 $q.= $lim.$field.
" = ".$placeholders[$k];
 
 1619                         foreach ($a_where as $k => $col)
 
 1621                                 $q.= $lim.$k.
" = %s";
 
 1637         function replace($a_table, $a_pk_columns, $a_other_columns)
 
 1640                 $a_columns = array_merge($a_pk_columns, $a_other_columns);
 
 1642                 $field_values = array();
 
 1643                 $placeholders = array();
 
 1648                 foreach ($a_columns as $k => $col)
 
 1651                         $placeholders[] = 
"%s";
 
 1652                         $placeholders2[] = 
":$k";
 
 1656                         if ($col[0] == 
'integer' && !is_null($col[1]))
 
 1658                                 $col[1] = (int) $col[1];
 
 1661                         $values[] = $col[1];
 
 1662                         $field_values[$k] = $col[1];
 
 1663                         if ($col[0] == 
"blob" || $col[0] == 
"clob")
 
 1671                         $st = $this->db->prepare(
"REPLACE INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
 
 1673                         $this->
handleError($st, 
"insert / prepare/execute(".$a_table.
")");
 
 1674                         $r = $st->execute($field_values);
 
 1676                         $this->
handleError($r, 
"insert / prepare/execute(".$a_table.
")");
 
 1681                         $q = 
"REPLACE INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
 
 1682                                 implode($placeholders,
",").
")";
 
 1703                 return $a_st->free();
 
 1723                 return $a_set->numRows();
 
 1741         function in($a_field, $a_values, $negate = 
false, $a_type = 
"")
 
 1743                 if (count($a_values) == 0)
 
 1749                         $str = $a_field.(($negate) ? 
" NOT" : 
"").
" IN (?".str_repeat(
",?", count($a_values) - 1).
")";
 
 1753                         $str = $a_field.(($negate) ? 
" NOT" : 
"").
" IN (";
 
 1755                         foreach ($a_values as $v)
 
 1757                                 $str.= $sep.$this->quote($v, $a_type);
 
 1771                 if (!is_array($a_arr))
 
 1777                         $type_arr = array_fill(0, $a_cnt, $a_type);
 
 1781                         $type_arr = array();
 
 1783                 return array_merge($a_arr, $type_arr);
 
 1805         public function concat($a_values,$a_allow_null = 
true)
 
 1807                 if(!count($a_values))
 
 1812                 $concat = 
' CONCAT(';
 
 1814                 foreach($a_values as $field_info)
 
 1816                         $val = $field_info[0];
 
 1825                                 $concat .= 
'COALESCE(';
 
 1847         function substr($a_exp, $a_pos = 1, $a_len = -1)
 
 1852                         $lenstr = 
", ".$a_len;
 
 1854                 return " SUBSTR(".$a_exp.
", ".$a_pos.$lenstr.
") ";
 
 1865                 return " UPPER(".$a_exp.
") ";
 
 1876                 return " LOWER(".$a_exp.
") ";
 
 1886         public function locate($a_needle,$a_string,$a_start_pos = 1)
 
 1888                 $locate = 
' LOCATE( ';
 
 1889                 $locate .= $a_needle;
 
 1891                 $locate .= $a_string;
 
 1893                 $locate .= $a_start_pos;
 
 1904         function like($a_col, $a_type, $a_value = 
"?", $case_insensitive = 
true)
 
 1906                 if (!in_array($a_type, array(
"text", 
"clob", 
"blob")))
 
 1908                         $this->
raisePearError(
"Like: Invalid column type '".$a_type.
"'.", $this->error_class->FATAL);
 
 1910                 if ($a_value == 
"?")
 
 1912                         if ($case_insensitive)
 
 1914                                 return "UPPER(".$a_col.
") LIKE(UPPER(?))";
 
 1918                                 return $a_col .
" LIKE(?)";
 
 1923                         if ($case_insensitive)
 
 1926                                 return " UPPER(".$a_col.
") LIKE(UPPER(".$this->
quote($a_value, 
'text').
"))";
 
 1931                                 return " ".$a_col.
" LIKE(".$this->
quote($a_value, 
'text').
")";
 
 1940         function equals($a_col, $a_value, $a_type, $a_empty_or_null = 
false)
 
 1942                 if (!$a_empty_or_null || $a_value != 
"")
 
 1944                         return $a_col.
" = ".$this->
quote($a_value, $a_type);
 
 1948                         return "(".$a_col.
" = '' OR $a_col IS NULL)";
 
 1955         function equalsNot($a_col, $a_value, $a_type, $a_empty_or_null = 
false)
 
 1957                 if (!$a_empty_or_null)
 
 1959                         return $a_col.
" <> ".$this->
quote($a_value, $a_type);
 
 1963                         return "(".$a_col.
" <> ".$this->
quote($a_value, $a_type). 
" OR ".
 
 1968                         return "(".$a_col.
" <> '' AND $a_col IS NOT NULL)";
 
 1980                 return "FROM_UNIXTIME(".$a_expr.
")";
 
 1988                 return "UNIX_TIMESTAMP()";
 
 2014                 if (is_array($tables))
 
 2016                         if (in_array($a_table, $tables))
 
 2034                 $column_visibility = 
false;
 
 2035                 $manager = $this->db->loadModule(
'Manager');
 
 2036                 $r = $manager->listTableFields($a_table);
 
 2040                         foreach($r as $field)
 
 2042                                 if ($field == $a_column_name)
 
 2044                                         $column_visibility = 
true;
 
 2049                 return $column_visibility;
 
 2059                 $manager = $this->db->loadModule(
'Manager');
 
 2060                 $r = $manager->listTables();
 
 2080                 if (is_array($sequences))
 
 2082                         if (in_array($a_sequence, $sequences))
 
 2097                 $manager = $this->db->loadModule(
'Manager');
 
 2098                 $r = $manager->listSequences();
 
 2116         function quote($a_query, $a_type = null)
 
 2118                 if ($a_query == 
"" && is_null($a_type))
 
 2124                 if($a_type == 
'integer' && !is_null($a_query))
 
 2126                         return (
int) $a_query;
 
 2129                 if ($a_type == 
"blob" || $a_type == 
"clob")
 
 2131                         $this->
raisePearError(
"ilDB::quote: Quoting not allowed on type '".$a_type.
"'. Please use ilDB->insert and ilDB->update to write clobs.", $this->error_class->FATAL);
 
 2134                 return $this->db->quote($a_query, $a_type);
 
 2146                 return $this->db->quoteIdentifier($a_identifier);
 
 2161                 if (!$this->db->supports(
'transactions'))
 
 2163                         $this->
raisePearError(
"ilDB::beginTransaction: Transactions are not supported.", $this->error_class->FATAL);
 
 2165                 $res = $this->db->beginTransaction();
 
 2175                 $res = $this->db->commit();
 
 2185                 $res = $this->db->rollback();
 
 2195         abstract public function lockTables($a_tables);
 
 2220                 $res = $this->db->autoExecute($a_tablename,$a_fields,$a_mode,$a_where);
 
 2236                 $res = $this->db->lastInsertId();
 
 2256                 $set = $this->db->query($sql);
 
 2279                 $set = $this->
query($sql);
 
 2280                 $r = $set->fetchRow($mode);
 
 2295                 $this->sub_type = (string)$a_value;