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);
396 $this->use_slave = $a_val;
413 $a_level = $this->error_class->FATAL;
423 $stack = $e->getTraceAsString();
426 if(is_object($ilLog))
429 $a_res->getMessage().
"<br />".$a_res->getUserInfo().
"<br />".$stack, $a_level);
443 $a_level = $this->error_class->FATAL;
458 $this->db->loadModule(
'Extended');
483 if ($a_collation !=
"")
485 $sql =
"CREATE DATABASE ".$a_name.
486 " CHARACTER SET ".$a_charset.
487 " COLLATE ".$a_collation;
491 $sql =
"CREATE DATABASE ".$a_name.
492 " CHARACTER SET ".$a_charset;
495 return $this->
query($sql,
false);
506 function createTable($a_name, $a_definition_array, $a_drop_table =
false,
507 $a_ignore_erros =
false)
512 $this->
raisePearError(
"ilDB Error: createTable(".$a_name.
")<br />".
519 $this->
raisePearError(
"ilDB Error: createTable(".$a_name.
")<br />".
530 $manager = $this->db->loadModule(
'Manager');
531 $r = $manager->createTable($a_name, $a_definition_array,
$options);
533 return $this->
handleError($r,
"createTable(".$a_name.
")");
552 function dropTable($a_name, $a_error_if_not_existing =
true)
554 if (!$a_error_if_not_existing)
557 if (!in_array($a_name, $tables))
563 $manager = $this->db->loadModule(
'Manager');
568 $constraints = $manager->listTableConstraints($a_name);
569 $this->
handleError($constraints,
"dropTable(".$a_name.
"), listTableConstraints");
570 foreach ($constraints as $c)
572 if (
substr($c, 0, 4) !=
"sys_")
574 $r = $manager->dropConstraint($a_name, $c);
575 $this->
handleError($r,
"dropTable(".$a_name.
"), dropConstraint");
580 $indexes = $manager->listTableIndexes($a_name);
581 $this->
handleError($indexes,
"dropTable(".$a_name.
"), listTableIndexes");
582 foreach ($indexes as $i)
584 $r = $manager->dropIndex($a_name, $i);
585 $this->
handleError($r,
"dropTable(".$a_name.
"), dropIndex");
590 $seqs = $manager->listSequences();
591 if (in_array($a_name, $seqs))
593 $r = $manager->dropSequence($a_name);
594 $this->
handleError($r,
"dropTable(".$a_name.
"), dropSequence");
598 $r = $manager->dropTable($a_name);
600 return $this->
handleError($r,
"dropTable(".$a_name.
")");
610 if ($a_options ==
"")
612 $a_options = array();
615 $manager = $this->db->loadModule(
'Manager');
616 $r = $manager->alterTable($a_name, $a_changes,
false);
618 return $this->
handleError($r,
"alterTable(".$a_name.
")");
632 $manager = $this->db->loadModule(
'Manager');
636 $this->
raisePearError(
"ilDB Error: addTableColumn(".$a_table.
", ".$a_column.
")<br />".
641 $this->
raisePearError(
"ilDB Error: addTableColumn(".$a_table.
", ".$a_column.
")<br />".
647 $a_column => $a_attributes
651 $r = $manager->alterTable($a_table, $changes,
false);
653 return $this->
handleError($r,
"addTableColumn(".$a_table.
", ".$a_column.
")");
666 $manager = $this->db->loadModule(
'Manager');
674 $r = $manager->alterTable($a_table, $changes,
false);
676 return $this->
handleError($r,
"dropTableColumn(".$a_table.
", ".$a_column.
")");
689 $manager = $this->db->loadModule(
'Manager');
690 $reverse = $this->db->loadModule(
'Reverse');
691 $def = $reverse->getTableFieldDefinition($a_table, $a_column);
693 $this->
handleError($def,
"modifyTableColumn(".$a_table.
")");
695 if (is_file(
"./Services/Database/classes/class.ilDBAnalyzer.php"))
697 include_once(
"./Services/Database/classes/class.ilDBAnalyzer.php");
701 include_once(
"../Services/Database/classes/class.ilDBAnalyzer.php");
704 $best_alt = $analyzer->getBestDefinitionAlternative($def);
705 $def = $def[$best_alt];
706 unset($def[
"nativetype"]);
707 unset($def[
"mdb2type"]);
710 $type = ($a_attributes[
"type"] !=
"")
711 ? $a_attributes[
"type"]
713 foreach ($def as $k => $v)
715 if ($k !=
"type" && !in_array($k, $this->allowed_attributes[$type]))
721 foreach ($a_attributes as $k => $v)
723 $check_array[$k] = $v;
727 $this->
raisePearError(
"ilDB Error: modifyTableColumn(".$a_table.
", ".$a_column.
")<br />".
732 if ($this->getDbType() ==
"oracle")
734 if ($def[
"notnull"] ==
true && ($a_attributes[
"notnull"] ==
true
735 || !isset($a_attributes[
"notnull"])))
737 unset($def[
"notnull"]);
738 unset($a_attributes[
"notnull"]);
740 if ($def[
"notnull"] ==
false && ($a_attributes[
"notnull"] ==
false
741 || !isset($a_attributes[
"notnull"])))
743 unset($def[
"notnull"]);
744 unset($a_attributes[
"notnull"]);
747 foreach ($a_attributes as $a => $v)
752 $a_attributes[
"definition"] = $def;
756 $a_column => $a_attributes
760 $r = $manager->alterTable($a_table, $changes,
false);
762 return $this->
handleError($r,
"modifyTableColumn(".$a_table.
")");
778 $this->
raisePearError(
"ilDB Error: renameTableColumn(".$a_table.
",".$a_column.
",".$a_new_column.
")<br />".
782 $manager = $this->db->loadModule(
'Manager');
783 $reverse = $this->db->loadModule(
'Reverse');
784 $def = $reverse->getTableFieldDefinition($a_table, $a_column);
786 $this->
handleError($def,
"renameTableColumn(".$a_table.
",".$a_column.
",".$a_new_column.
")");
788 if (is_file(
"./Services/Database/classes/class.ilDBAnalyzer.php"))
790 include_once(
"./Services/Database/classes/class.ilDBAnalyzer.php");
794 include_once(
"../Services/Database/classes/class.ilDBAnalyzer.php");
798 $best_alt = $analyzer->getBestDefinitionAlternative($def);
799 $def = $def[$best_alt];
800 unset($def[
"nativetype"]);
801 unset($def[
"mdb2type"]);
803 $f[
"definition"] = $def;
804 $f[
"name"] = $a_new_column;
812 $r = $manager->alterTable($a_table, $changes,
false);
814 return $this->
handleError($r,
"renameTableColumn(".$a_table.
",".$a_column.
",".$a_new_column.
")");
828 $this->
raisePearError(
"ilDB Error: renameTable(".$a_name.
",".$a_new_name.
")<br />".
832 $manager = $this->db->loadModule(
'Manager');
833 $r = $manager->alterTable($a_name, array(
"name" => $a_new_name),
false);
835 $query =
"UPDATE abstraction_progress ".
836 "SET table_name = ".$this->db->quote($a_new_name,
'text').
" ".
837 "WHERE table_name = ".$this->db->quote($a_name,
'text');
840 return $this->
handleError($r,
"renameTable(".$a_name.
",".$a_new_name.
")");
852 $manager = $this->db->loadModule(
'Manager');
855 foreach ($a_fields as $f)
857 $fields[$f] = array();
859 $definition = array (
863 $r = $manager->createConstraint($a_table,
866 return $this->
handleError($r,
"addPrimaryKey(".$a_table.
")");
885 $manager = $this->db->loadModule(
'Manager');
887 $r = $manager->dropConstraint($a_table,
890 return $this->
handleError($r,
"dropPrimaryKey(".$a_table.
")");
900 function addIndex($a_table, $a_fields, $a_name =
"in", $a_fulltext =
false)
902 $manager = $this->db->loadModule(
'Manager');
907 $this->
raisePearError(
"ilDB Error: addIndex(".$a_table.
",".$a_name.
")<br />".
912 foreach ($a_fields as $f)
914 $fields[$f] = array();
916 $definition = array (
922 $r = $manager->createIndex($a_table, $this->
constraintName($a_table, $a_name), $definition);
932 return $this->
handleError($r,
"addIndex(".$a_table.
")");
959 $manager = $this->db->loadModule(
'Manager');
960 $reverse = $this->db->loadModule(
'Reverse');
963 foreach($manager->listTableIndexes($a_table) as $idx_name)
965 $def = $reverse->getTableIndexDefinition($a_table,$idx_name);
966 $idx_fields = array_keys((array) $def[
'fields']);
968 if($idx_fields === $a_fields)
985 $manager = $this->db->loadModule(
'Manager');
986 $reverse = $this->db->loadModule(
'Reverse');
989 foreach($manager->listTableIndexes($a_table) as $idx_name)
991 $def = $reverse->getTableIndexDefinition($a_table,$idx_name);
992 $idx_fields = array_keys((array) $def[
'fields']);
994 if($idx_fields === $a_fields)
996 return $this->
dropIndex($a_table, $idx_name);
1013 $manager = $this->db->loadModule(
'Manager');
1017 $r = $manager->dropIndex($a_table, $this->
constraintName($a_table, $a_name));
1021 $this->dropFulltextIndex($a_table, $a_name);
1024 return $this->
handleError($r,
"dropIndex(".$a_table.
")");
1036 $manager = $this->db->loadModule(
'Manager');
1041 $this->
raisePearError(
"ilDB Error: addUniqueConstraint(".$a_table.
",".$a_name.
")<br />".
1046 foreach ($a_fields as $f)
1048 $fields[$f] = array();
1050 $definition = array (
1055 $r = $manager->createConstraint($a_table, $this->
constraintName($a_table, $a_name), $definition);
1057 return $this->
handleError($r,
"addUniqueConstraint(".$a_table.
")");
1065 $manager = $this->db->loadModule(
'Manager');
1067 $r = $manager->createSequence($a_table_name, $a_start);
1069 return $this->
handleError($r,
"createSequence(".$a_table_name.
")");
1078 $manager = $this->db->loadModule(
'Manager');
1080 $r = $manager->dropSequence($a_table_name);
1082 return $this->
handleError($r,
"dropSequence(".$a_table_name.
")");
1092 if (!preg_match (
"/^[a-z]+[_a-z0-9]*$/", $a_name))
1094 $this->error_str =
"Table name must only contain _a-z0-9 and must start with a-z.";
1100 $this->error_str =
"Invalid table name '".$a_name.
"' (Reserved Word).";
1104 if (strtolower(
substr($a_name, 0, 4)) ==
"sys_")
1106 $this->error_str =
"Invalid table name '".$a_name.
"'. Name must not start with 'sys_'.";
1110 if (strlen($a_name) > 22)
1112 $this->error_str =
"Invalid table name '".$a_name.
"'. Maximum table identifer lenght is 22 bytes.";
1126 foreach ($a_cols as $col => $def)
1163 if (!in_array($a_def[
"type"], array(
"text",
"integer",
"float",
"date",
"time",
"timestamp",
"clob",
"blob")))
1165 switch ($a_def[
"type"])
1168 $this->error_str =
"Invalid column type '".$a_def[
"type"].
"'. Use integer(1) instead.";
1172 $this->error_str =
"Invalid column type '".$a_def[
"type"].
"'. Use float or integer instead.";
1176 $this->error_str =
"Invalid column type '".$a_def[
"type"].
"'. Allowed types are: ".
1177 "text, integer, float, date, time, timestamp, clob and blob.";
1184 foreach ($a_def as $k => $v)
1188 $this->error_str =
"Attribute '".$k.
"' is not allowed for column type '".$a_def[
"type"].
"'.";
1194 switch ($a_def[
"type"])
1197 if ($a_def[
"length"] < 1 || $a_def[
"length"] > 4000)
1199 if (!$a_modify_mode || isset($a_def[
"length"]))
1201 $this->error_str =
"Invalid length '".$a_def[
"length"].
"' for type text.".
1202 " Length must be >=1 and <= 4000.";
1209 if (!in_array($a_def[
"length"], array(1, 2, 3, 4, 8)))
1211 if (!$a_modify_mode || isset($a_def[
"length"]))
1213 $this->error_str =
"Invalid length '".$a_def[
"length"].
"' for type integer.".
1214 " Length must be 1, 2, 3, 4 or 8 (bytes).";
1218 if ($a_def[
"unsigned"])
1220 $this->error_str =
"Unsigned attribut must not be true for type integer.";
1236 if (!preg_match (
"/^[a-z]+[_a-z0-9]*$/", $a_name))
1238 $this->error_str =
"Invalid column name '".$a_name.
"'. Column name must only contain _a-z0-9 and must start with a-z.";
1244 $this->error_str =
"Invalid column name '".$a_name.
"' (Reserved Word).";
1248 if (strtolower(
substr($a_name, 0, 4)) ==
"sys_")
1250 $this->error_str =
"Invalid column name '".$a_name.
"'. Name must not start with 'sys_'.";
1254 if (strlen($a_name) > 30)
1256 $this->error_str =
"Invalid column name '".$a_name.
"'. Maximum column identifer lenght is 30 bytes.";
1270 if (!preg_match (
"/^[a-z]+[_a-z0-9]*$/", $a_name))
1272 $this->error_str =
"Invalid column name '".$a_name.
"'. Column name must only contain _a-z0-9 and must start with a-z.";
1278 $this->error_str =
"Invalid column name '".$a_name.
"' (Reserved Word).";
1282 if (strlen($a_name) > 3)
1284 $this->error_str =
"Invalid index name '".$a_name.
"'. Maximum index identifer lenght is 3 bytes.";
1303 return $a_constraint;
1312 include_once(
"./Services/Database/classes/class.ilDBMySQL.php");
1314 if (in_array(strtoupper($a_word), $mysql_reserved_words))
1318 include_once(
"./Services/Database/classes/class.ilDBOracle.php");
1320 if (in_array(strtoupper($a_word), $oracle_reserved_words))
1324 include_once(
"./Services/Database/classes/class.ilDBPostgreSQL.php");
1326 if (in_array(strtoupper($a_word), $postgres_reserved_words))
1347 function query($sql, $a_handle_error =
true)
1351 if (is_object($ilBench))
1353 $ilBench->startDbBench($sql);
1355 $r = $this->db->query($sql);
1356 if (is_object($ilBench))
1358 $ilBench->stopDbBench();
1361 if ($a_handle_error)
1376 function queryF($a_query, $a_types, $a_values)
1378 if (!is_array($a_types) || !is_array($a_values) ||
1379 count($a_types) != count($a_values))
1381 $this->
raisePearError(
"ilDB::queryF: Types and values must be arrays of same size. ($a_query)");
1383 $quoted_values = array();
1384 foreach($a_types as $k =>
$t)
1386 $quoted_values[] = $this->
quote($a_values[$k],
$t);
1388 $query = vsprintf($a_query, $quoted_values);
1402 if (!is_array($a_types) || !is_array($a_values) ||
1403 count($a_types) != count($a_values))
1405 $this->
raisePearError(
"ilDB::manipulateF: types and values must be arrays of same size. ($a_query)");
1407 $quoted_values = array();
1408 foreach($a_types as $k =>
$t)
1410 $quoted_values[] = $this->
quote($a_values[$k],
$t);
1412 $query = vsprintf($a_query, $quoted_values);
1422 $pos1 = strpos(strtolower($sql),
"from ");
1426 $tablef =
substr($sql, $pos1+5);
1427 $pos2 = strpos(strtolower($tablef),
" ");
1430 $table =
substr($tablef, 0, $pos2);
1437 if (trim($table) !=
"")
1439 if (!is_array($this->ttt) || !in_array($table, $this->ttt))
1442 $this->ttt[] = $table;
1447 echo
"<br><b>".$sql.
"</b>";
1456 $this->db->setLimit($a_limit, $a_offset);
1467 $r = $this->db->nextId($a_table_name,
false);
1469 return $this->
handleError($r,
"nextId(".$a_table_name.
")");
1486 if (is_object($ilBench))
1488 $ilBench->startDbBench($sql);
1490 $r = $this->db->exec($sql);
1491 if (is_object($ilBench))
1493 $ilBench->stopDbBench();
1496 return $this->
handleError($r,
"manipulate(".$sql.
")");
1507 function prepare($a_query, $a_types = null, $a_result_types = null)
1509 $res = $this->db->prepare($a_query, $a_types, $a_result_types);
1539 $res = $a_stmt->execute($a_data);
1555 $res = $this->db->extended->executeMultiple($a_stmt,$a_data);
1557 return $this->
handleError(
$res,
"executeMultiple(".$a_stmt->query.
")");
1569 $field_values = array();
1570 $placeholders = array();
1575 foreach ($a_columns as $k => $col)
1578 $placeholders[] =
"%s";
1579 $placeholders2[] =
":$k";
1583 if ($col[0] ==
'integer' && !is_null($col[1]))
1585 $col[1] = (int) $col[1];
1588 $values[] = $col[1];
1589 $field_values[$k] = $col[1];
1590 if ($col[0] ==
"blob" || $col[0] ==
"clob")
1598 $st = $this->db->prepare(
"INSERT INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
1601 $this->
handleError($st,
"insert / prepare/execute(".$a_table.
")");
1603 $r = $st->execute($field_values);
1607 $this->
handleError($r,
"insert / prepare/execute(".$a_table.
")");
1612 $q =
"INSERT INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
1613 implode($placeholders,
",").
")";
1627 function update($a_table, $a_columns, $a_where)
1630 $field_values = array();
1631 $placeholders = array();
1636 foreach ($a_columns as $k => $col)
1639 $placeholders[] =
"%s";
1640 $placeholders2[] =
":$k";
1644 if ($col[0] ==
'integer' && !is_null($col[1]))
1646 $col[1] = (int) $col[1];
1649 $values[] = $col[1];
1650 $field_values[$k] = $col[1];
1651 if ($col[0] ==
"blob" || $col[0] ==
"clob")
1660 $q =
"UPDATE ".$a_table.
" SET ";
1662 foreach ($fields as $k => $field)
1664 $q.= $lim.$field.
" = ".$placeholders2[$k];
1669 foreach ($a_where as $k => $col)
1671 $q.= $lim.$k.
" = ".$this->
quote($col[1], $col[0]);
1675 $r = $st->execute($field_values);
1678 $this->
handleError($r,
"update / prepare/execute(".$a_table.
")");
1683 foreach ($a_where as $k => $col)
1686 $values[] = $col[1];
1687 $field_values[$k] = $col;
1689 $q =
"UPDATE ".$a_table.
" SET ";
1691 foreach ($fields as $k => $field)
1693 $q.= $lim.$field.
" = ".$placeholders[$k];
1698 foreach ($a_where as $k => $col)
1700 $q.= $lim.$k.
" = %s";
1716 function replace($a_table, $a_pk_columns, $a_other_columns)
1719 $a_columns = array_merge($a_pk_columns, $a_other_columns);
1721 $field_values = array();
1722 $placeholders = array();
1727 foreach ($a_columns as $k => $col)
1730 $placeholders[] =
"%s";
1731 $placeholders2[] =
":$k";
1735 if ($col[0] ==
'integer' && !is_null($col[1]))
1737 $col[1] = (int) $col[1];
1740 $values[] = $col[1];
1741 $field_values[$k] = $col[1];
1742 if ($col[0] ==
"blob" || $col[0] ==
"clob")
1750 $st = $this->db->prepare(
"REPLACE INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
1752 $this->
handleError($st,
"insert / prepare/execute(".$a_table.
")");
1753 $r = $st->execute($field_values);
1755 $this->
handleError($r,
"insert / prepare/execute(".$a_table.
")");
1760 $q =
"REPLACE INTO ".$a_table.
" (".implode($fields,
",").
") VALUES (".
1761 implode($placeholders,
",").
")";
1782 return $a_st->free();
1802 return $a_set->numRows();
1820 function in($a_field, $a_values, $negate =
false, $a_type =
"")
1822 if (count($a_values) == 0)
1828 $str = $a_field.(($negate) ?
" NOT" :
"").
" IN (?".str_repeat(
",?", count($a_values) - 1).
")";
1832 $str = $a_field.(($negate) ?
" NOT" :
"").
" IN (";
1834 foreach ($a_values as $v)
1836 $str.= $sep.$this->quote($v, $a_type);
1850 if (!is_array($a_arr))
1856 $type_arr = array_fill(0, $a_cnt, $a_type);
1860 $type_arr = array();
1862 return array_merge($a_arr, $type_arr);
1884 public function concat($a_values,$a_allow_null =
true)
1886 if(!count($a_values))
1891 $concat =
' CONCAT(';
1893 foreach($a_values as $field_info)
1895 $val = $field_info[0];
1904 $concat .=
'COALESCE(';
1926 function substr($a_exp, $a_pos = 1, $a_len = -1)
1931 $lenstr =
", ".$a_len;
1933 return " SUBSTR(".$a_exp.
", ".$a_pos.$lenstr.
") ";
1944 return " UPPER(".$a_exp.
") ";
1955 return " LOWER(".$a_exp.
") ";
1965 public function locate($a_needle,$a_string,$a_start_pos = 1)
1967 $locate =
' LOCATE( ';
1968 $locate .= $a_needle;
1970 $locate .= $a_string;
1972 $locate .= $a_start_pos;
1983 function like($a_col, $a_type, $a_value =
"?", $case_insensitive =
true)
1985 if (!in_array($a_type, array(
"text",
"clob",
"blob")))
1987 $this->
raisePearError(
"Like: Invalid column type '".$a_type.
"'.", $this->error_class->FATAL);
1989 if ($a_value ==
"?")
1991 if ($case_insensitive)
1993 return "UPPER(".$a_col.
") LIKE(UPPER(?))";
1997 return $a_col .
" LIKE(?)";
2002 if ($case_insensitive)
2005 return " UPPER(".$a_col.
") LIKE(UPPER(".$this->
quote($a_value,
'text').
"))";
2010 return " ".$a_col.
" LIKE(".$this->
quote($a_value,
'text').
")";
2019 function equals($a_col, $a_value, $a_type, $a_empty_or_null =
false)
2021 if (!$a_empty_or_null || $a_value !=
"")
2023 return $a_col.
" = ".$this->
quote($a_value, $a_type);
2027 return "(".$a_col.
" = '' OR $a_col IS NULL)";
2034 function equalsNot($a_col, $a_value, $a_type, $a_empty_or_null =
false)
2036 if (!$a_empty_or_null)
2038 return $a_col.
" <> ".$this->
quote($a_value, $a_type);
2042 return "(".$a_col.
" <> ".$this->
quote($a_value, $a_type).
" OR ".
2047 return "(".$a_col.
" <> '' AND $a_col IS NOT NULL)";
2059 return "FROM_UNIXTIME(".$a_expr.
")";
2067 return "UNIX_TIMESTAMP()";
2093 if (is_array($tables))
2095 if (in_array($a_table, $tables))
2113 $column_visibility =
false;
2114 $manager = $this->db->loadModule(
'Manager');
2115 $r = $manager->listTableFields($a_table);
2119 foreach($r as $field)
2121 if ($field == $a_column_name)
2123 $column_visibility =
true;
2128 return $column_visibility;
2140 if (is_file(
"./Services/Database/classes/class.ilDBAnalyzer.php"))
2142 include_once(
"./Services/Database/classes/class.ilDBAnalyzer.php");
2146 include_once(
"../Services/Database/classes/class.ilDBAnalyzer.php");
2149 $cons = $analyzer->getConstraintsInformation($a_table);
2150 foreach ($cons as $c)
2152 if ($c[
"type"] ==
"unique" && count($a_fields) == count($c[
"fields"]))
2155 foreach ($a_fields as $f)
2157 if (!isset($c[
"fields"][$f]))
2179 $manager = $this->db->loadModule(
'Manager');
2180 $r = $manager->listTables();
2200 if (is_array($sequences))
2202 if (in_array($a_sequence, $sequences))
2217 $manager = $this->db->loadModule(
'Manager');
2218 $r = $manager->listSequences();
2236 function quote($a_query, $a_type = null)
2238 if ($a_query ==
"" && is_null($a_type))
2244 if($a_type ==
'integer' && !is_null($a_query))
2246 return (
int) $a_query;
2249 if ($a_type ==
"blob" || $a_type ==
"clob")
2251 $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);
2254 return $this->db->quote($a_query, $a_type);
2266 return $this->db->quoteIdentifier($a_identifier);
2281 if (!$this->db->supports(
'transactions'))
2283 $this->
raisePearError(
"ilDB::beginTransaction: Transactions are not supported.", $this->error_class->FATAL);
2285 $res = $this->db->beginTransaction();
2295 $res = $this->db->commit();
2305 $res = $this->db->rollback();
2315 abstract public function lockTables($a_tables);
2340 $res = $this->db->autoExecute($a_tablename,$a_fields,$a_mode,$a_where);
2356 $res = $this->db->lastInsertId();
2376 $set = $this->db->query($sql);
2399 $set = $this->
query($sql);
2400 $r = $set->fetchRow($mode);
2415 $this->sub_type = (string)$a_value;