19declare(strict_types=1);
41 protected ?PDO
$pdo =
null;
47 protected string $dsn =
'';
53 PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
62 public function connect(
bool $return_false_for_error =
false): ?bool
70 }
catch (Exception
$e) {
71 $this->error_code =
$e->getCode();
72 if ($return_false_for_error) {
78 return ($this->pdo->errorCode() === PDO::ERR_NONE);
112 public function createDatabase(
string $a_name,
string $a_charset =
"utf8",
string $a_collation =
""): bool
118 $this->
query($this->manager->getQueryUtils()->createDatabase($a_name, $a_charset, $a_collation));
120 }
catch (PDOException) {
130 if ($this->pdo instanceof PDO) {
131 return $this->pdo->errorCode();
142 $clientIniFile =
$ini;
143 } elseif (
$DIC->offsetExists(
'ilClientIniFile')) {
144 $clientIniFile =
$DIC[
'ilClientIniFile'];
146 throw new InvalidArgumentException(
'$tmpClientIniFile is not an instance of ilIniFile');
149 $this->
setUsername($clientIniFile->readVariable(
"db",
"user"));
150 $this->
setHost($clientIniFile->readVariable(
"db",
"host"));
151 $this->
setPort((
int) $clientIniFile->readVariable(
"db",
"port"));
152 $this->
setPassword((
string) $clientIniFile->readVariable(
"db",
"pass"));
153 $this->
setDbname($clientIniFile->readVariable(
"db",
"name"));
154 $this->
setDBType($clientIniFile->readVariable(
"db",
"type"));
168 public function quoteIdentifier(
string $identifier,
bool $check_option =
false): string
170 return '`' . preg_replace(
'/[^a-zA-Z0-9_$]/',
'', $identifier) .
'`';
176 abstract public function nextId(
string $table_name):
int;
184 bool $drop_table =
false,
185 bool $ignore_erros =
false
201 return $this->manager->createTable($table_name, $fields, []);
206 foreach ($a_cols as $col => $def) {
207 if (!$this->checkColumn($col, $def)) {
217 if (!$this->checkColumnName($a_col)) {
220 return $this->checkColumnDefinition($a_def);
225 return $this->field_definition->checkColumnDefinition($a_def);
230 return $this->field_definition->checkColumnName($a_name);
236 public function addPrimaryKey(
string $table_name, array $primary_keys): bool
238 assert(is_array($primary_keys));
241 foreach ($primary_keys as
$f) {
248 $this->manager->createConstraint(
250 $this->constraintName($table_name, $this->getPrimaryKeyIdentifier()),
262 foreach ($this->manager->listTableIndexes($table_name) as $idx_name) {
263 $def = $this->reverse->getTableIndexDefinition($table_name, $idx_name);
264 $idx_fields = array_keys($def[
'fields']);
266 if ($idx_fields === $fields) {
267 return $this->dropIndex($table_name, $idx_name);
281 $this->manager->createSequence($table_name, $start);
287 $result = $this->pdo->prepare(
"SHOW TABLES LIKE :table_name");
288 $result->execute([
'table_name' => $table_name]);
289 $return = $result->rowCount();
290 $result->closeCursor();
299 return in_array($column_name, $fields,
true);
305 public function addTableColumn(
string $table_name,
string $column_name, array $attributes): bool
307 if (!$this->checkColumnName($column_name)) {
308 throw new ilDatabaseException(
"ilDB Error: addTableColumn(" . $table_name .
", " . $column_name .
")");
310 if (!$this->checkColumnDefinition($attributes)) {
311 throw new ilDatabaseException(
"ilDB Error: addTableColumn(" . $table_name .
", " . $column_name .
")");
316 $column_name => $attributes,
320 return $this->manager->alterTable($table_name, $changes,
false);
326 public function dropTable(
string $table_name,
bool $error_if_not_existing =
true): bool
329 $tables = $ilDBPdoManager->listTables();
330 $table_exists = in_array($table_name, $tables);
331 if (!$table_exists && $error_if_not_existing) {
336 $sequences = $ilDBPdoManager->listSequences();
337 if (in_array($table_name, $sequences)) {
338 $ilDBPdoManager->dropSequence($table_name);
343 $ilDBPdoManager->dropTable($table_name);
355 $ilBench =
$DIC[
'ilBench'] ??
null;
357 $query = $this->appendLimit($query);
361 $ilBench->startDbBench($query);
363 $res = $this->pdo->query($query);
365 $ilBench->stopDbBench();
367 }
catch (PDOException
$e) {
371 $err = $this->pdo->errorCode();
372 if ($err !== PDO::ERR_NONE) {
373 $info = $this->pdo->errorInfo();
374 $info_message =
$info[2];
384 while (
$data = $statement->
fetch($fetch_mode)) {
393 $this->manager->dropSequence($table_name);
408 return $this->manager->alterTable($table_name, $changes,
false);
414 public function renameTableColumn(
string $table_name,
string $column_old_name,
string $column_new_name): bool
417 if (!$this->checkColumnName($column_new_name)) {
418 throw new ilDatabaseException(
"ilDB Error: renameTableColumn(" . $table_name .
"," . $column_old_name .
"," . $column_new_name .
")");
421 $def = $this->reverse->getTableFieldDefinition($table_name, $column_old_name);
424 $best_alt = $analyzer->getBestDefinitionAlternative($def);
425 $def = $def[$best_alt];
426 unset($def[
"nativetype"]);
427 unset($def[
"mdb2type"]);
429 $f[
"definition"] = $def;
430 $f[
"name"] = $column_new_name;
434 $column_old_name =>
$f,
438 return $this->manager->alterTable($table_name, $changes,
false);
441 public function insert(
string $table_name, array $values):
int
445 foreach ($values as $key => $val) {
446 $real[] = $this->quote($val[1], $val[0]);
447 $fields[] = $this->quoteIdentifier($key);
449 $values_string = implode(
",", $real);
450 $fields_string = implode(
",", $fields);
451 $query =
"INSERT INTO " . $this->quoteIdentifier($table_name) .
" (" . $fields_string .
") VALUES (" . $values_string .
")";
453 $query = $this->sanitizeMB4StringIfNotSupported($query);
455 return (
int) $this->pdo->exec($query);
462 $query_result->closeCursor();
470 public function update(
string $table_name, array $columns, array $where):
int
475 $placeholders_full = [];
480 foreach ($columns as $k => $col) {
481 $field_value = $col[1];
483 $placeholders[] =
"%s";
484 $placeholders_full[] =
":$k";
487 if (($col[0] ===
"blob" || $col[0] ===
"clob" || $col[0] ===
'text') && is_string($field_value)) {
488 $field_value = $this->sanitizeMB4StringIfNotSupported($field_value);
492 if ($col[0] ===
'integer' && !is_null($field_value)) {
493 $field_value = (
int) $field_value;
496 $values[] = $field_value;
497 $field_values[$k] = $field_value;
498 if ($col[0] ===
"blob" || $col[0] ===
"clob") {
504 $q =
"UPDATE " . $this->quoteIdentifier($table_name) .
" SET ";
506 foreach ($fields as $k => $field) {
507 $q .= $lim . $this->quoteIdentifier($field) .
" = " . $placeholders_full[$k];
512 foreach ($where as $k => $col) {
513 $q .= $lim . $this->quoteIdentifier($k) .
" = " . $this->quote($col[1], $col[0]);
517 $r = $this->prepareManip(
$q, $types);
518 $this->execute($r, $field_values);
520 $num_affected_rows = $r->rowCount();
524 foreach ($where as $k => $col) {
527 $field_values[$k] = $col;
529 $q =
"UPDATE " . $this->quoteIdentifier($table_name) .
" SET ";
531 foreach ($fields as $k => $field) {
532 $q .= $lim . $this->quoteIdentifier($field) .
" = " . $placeholders[$k];
537 foreach (array_keys($where) as $k) {
538 $q .= $lim . $this->quoteIdentifier($k) .
" = %s";
542 $num_affected_rows = $this->manipulateF(
$q, $types, $values);
545 return $num_affected_rows;
554 $ilBench =
$DIC[
'ilBench'] ??
null;
556 $query = $this->sanitizeMB4StringIfNotSupported($query);
558 $ilBench->startDbBench($query);
560 $num_affected_rows = $this->pdo->exec($query);
562 $ilBench->stopDbBench();
564 }
catch (PDOException
$e) {
568 return (
int) $num_affected_rows;
573 $res = $statement->
fetch(PDO::FETCH_ASSOC);
574 if (
$res ===
null ||
$res ===
false) {
575 $statement->closeCursor();
588 public function quote($value, ?
string $type =
null): string
590 if ($value ===
null) {
594 $pdo_type = PDO::PARAM_STR;
602 if ($value === $this->now()) {
605 $value = (string) $value;
608 return (
string) (
int) $value;
610 $pdo_type = PDO::PARAM_INT;
611 $value = (string) $value;
615 $value = (string) $value;
616 $pdo_type = PDO::PARAM_STR;
620 return $this->pdo->quote((
string) $value, $pdo_type);
625 foreach ($this->manager->listTableIndexes($table_name) as $idx_name) {
626 $def = $this->reverse->getTableIndexDefinition($table_name, $idx_name);
627 $idx_fields = array_keys($def[
'fields']);
629 if ($idx_fields === $fields) {
637 public function addIndex(
string $table_name, array $fields,
string $index_name =
'',
bool $fulltext =
false): bool
639 assert(is_array($fields));
640 $this->field_definition->checkIndexName($index_name);
642 $definition_fields = [];
643 foreach ($fields as
$f) {
644 $definition_fields[
$f] = [];
647 'fields' => $definition_fields,
651 $this->manager->createIndex($table_name, $this->constraintName($table_name, $index_name), $definition);
652 } elseif ($this->supportsFulltext()) {
653 $this->addFulltextIndex($table_name, $fields, $index_name);
663 public function addFulltextIndex(
string $table, array $fields,
string $a_name =
"in"): bool
665 $i_name = $this->constraintName($table, $a_name) .
"_idx";
666 $f_str = implode(
",", $fields);
667 $q =
"ALTER TABLE $table ADD FULLTEXT $i_name ($f_str)";
677 $i_name = $this->constraintName($a_table, $a_name) .
"_idx";
678 $this->query(
"ALTER TABLE $a_table DROP FULLTEXT $i_name");
687 $set = $this->query(
"SHOW INDEX FROM " . $a_table);
688 while ($rec = $this->fetchAssoc($set)) {
689 if ($rec[
"Key_name"] === $a_name && $rec[
"Index_type"] ===
"FULLTEXT") {
713 return $a_constraint;
723 return $this->db_type;
728 $this->db_type = $type;
736 public static function getReservedWords(): array
744 $fd =
$ilDB->getFieldDefinition();
746 return $fd->getReservedMysql();
756 assert(is_array($tables));
757 $lock = $this->manager->getQueryUtils()->lock($tables);
758 $this->pdo->exec($lock);
767 $this->pdo->exec($this->manager->getQueryUtils()->unlock());
770 public function in(
string $field, array $values,
bool $negate =
false,
string $type =
""): string
772 return $this->manager->getQueryUtils()->in($field, $values, $negate, $type);
781 if (!is_array($types) || !is_array($values) || count($types) !== count($values)) {
782 throw new ilDatabaseException(
"ilDB::queryF: Types and values must be arrays of same size. ($query)");
785 foreach ($types as $k => $t) {
786 $quoted_values[] = $this->quote($values[$k], $t);
788 $query = vsprintf($query, $quoted_values);
790 return $this->query($query);
799 if (!is_array($types) || !is_array($values) || count($types) !== count($values)) {
800 throw new ilDatabaseException(
"ilDB::manipulateF: types and values must be arrays of same size. ($query)");
803 foreach ($types as $k => $t) {
804 $quoted_values[] = $this->quote($values[$k], $t);
806 $query = vsprintf($query, $quoted_values);
808 return $this->manipulate($query);
822 public function setLimit(
int $limit,
int $offset = 0): void
824 $this->limit = $limit;
825 $this->offset = $offset;
831 public function like(
string $column,
string $type,
string $value =
"?",
bool $case_insensitive =
true): string
833 return $this->manager->getQueryUtils()->like($column, $type, $value, $case_insensitive);
839 public function now(): string
841 return $this->manager->getQueryUtils()->now();
844 public function replace(
string $table, array $primary_keys, array $other_columns):
int
846 $a_columns = array_merge($primary_keys, $other_columns);
852 foreach ($a_columns as $k => $col) {
853 $fields[] = $this->quoteIdentifier($k);
854 $placeholders[] =
"%s";
855 $placeholders2[] =
":$k";
859 if ($col[0] ===
'integer' && !is_null($col[1])) {
860 $col[1] = (
int) $col[1];
866 $q =
"REPLACE INTO " . $table .
" (" . implode(
",", $fields) .
") VALUES (" . implode(
",", $placeholders) .
")";
868 return $this->manipulateF(
$q, $types, $values);
874 public function equals(
string $columns, $value,
string $type,
bool $emptyOrNull =
false): string
876 if (!$emptyOrNull || $value !=
"") {
877 return $columns .
" = " . $this->quote($value, $type);
880 return "(" . $columns .
" = '' OR $columns IS NULL)";
895 return $this->dbname;
900 $this->dbname = $dbname;
905 return $this->charset;
910 $this->charset = $charset;
915 return $this->username;
920 $this->username = $username;
925 return $this->password;
930 $this->password = $password;
945 $this->setUsername($user);
950 $this->setPort($port);
955 $this->setPassword($password);
960 $this->setHost($host);
966 public function upper(
string $expression): string
968 return " UPPER(" . $expression .
") ";
974 public function lower(
string $expression): string
976 return " LOWER(" . $expression .
") ";
979 public function substr(
string $a_exp,
int $a_pos = 1,
int $a_len = -1): string
983 $lenstr =
", " . $a_len;
985 return " SUBSTR(" . $a_exp .
", " . $a_pos . $lenstr .
") ";
1000 $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $a_status);
1012 if ($result ===
false) {
1013 throw new ilDatabaseException(implode(
', ', $stmt->errorInfo()), (
int) $stmt->errorCode());
1035 return match ($feature) {
1036 self::FEATURE_TRANSACTIONS => $this->supportsTransactions(),
1037 self::FEATURE_FULLTEXT => $this->supportsFulltext(),
1038 self::FEATURE_SLAVE => $this->supportsSlave(),
1048 return $this->manager->listTables();
1056 return match ($module) {
1059 default =>
throw new LogicException(
'module "' . $module .
'" not available'),
1068 return $this->field_definition->getAllowedAttributes();
1073 return in_array($sequence, $this->listSequences(),
true);
1078 return $this->manager->listSequences();
1081 public function concat(array $values,
bool $allow_null =
true): string
1083 return $this->manager->getQueryUtils()->concat($values, $allow_null);
1088 if ($this->limit !==
null && $this->offset !==
null) {
1089 $query .=
' LIMIT ' . $this->offset .
', ' . $this->limit;
1090 $this->limit =
null;
1091 $this->offset =
null;
1099 public function locate(
string $needle,
string $string,
int $start_pos = 1): string
1101 return $this->manager->getQueryUtils()->locate($needle, $string, $start_pos);
1109 $def = $this->reverse->getTableFieldDefinition($table, $column);
1112 $best_alt = $analyzer->getBestDefinitionAlternative($def);
1113 $def = $def[$best_alt];
1114 unset($def[
"nativetype"], $def[
"mdb2type"]);
1117 $ilDBPdoFieldDefinition = $this->field_definition;
1119 $type = $attributes[
"type"] ?? $def[
"type"];
1121 foreach (array_keys($def) as $k) {
1122 if ($k !==
"type" && !$ilDBPdoFieldDefinition->isAllowedAttribute($k, $type)) {
1126 $check_array = $def;
1127 foreach ($attributes as $k => $v) {
1128 $check_array[$k] = $v;
1130 if (!$this->checkColumnDefinition($check_array,
true)) {
1131 throw new ilDatabaseException(
"ilDB Error: modifyTableColumn(" . $table .
", " . $column .
")");
1134 foreach ($attributes as
$a => $v) {
1138 $attributes[
"definition"] = $def;
1142 $column => $attributes,
1146 return $this->manager->alterTable($table, $changes,
false);
1151 $a_st->closeCursor();
1161 $this->checkTableName($new_name);
1163 throw new ilDatabaseException(
"ilDB Error: renameTable(" . $name .
"," . $new_name .
")<br />" .
$e->getMessage(),
$e->getCode(),
$e);
1166 $this->manager->alterTable($name, [
"name" => $new_name],
false);
1167 if ($this->sequenceExists($name)) {
1168 $this->manager->alterTable(
1169 $this->getSequenceName($name),
1170 [
"name" => $this->getSequenceName($new_name)],
1187 return $this->field_definition->checkTableName($a_name);
1201 if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1205 return $this->pdo->beginTransaction();
1213 if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1217 return $this->pdo->commit();
1225 if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1229 return $this->pdo->rollBack();
1232 public function dropIndex(
string $a_table,
string $a_name =
"i1"): bool
1234 return $this->manager->dropIndex($a_table, $a_name);
1239 $this->storage_engine = $storage_engine;
1244 return $this->storage_engine;
1247 public function queryCol(
string $query,
int $type = PDO::FETCH_ASSOC,
int $colnum = 0): array
1249 $type = match ($type) {
1252 default => PDO::FETCH_ASSOC,
1255 return $this->pdo->query($query, PDO::FETCH_ASSOC)->fetchAll(PDO::FETCH_COLUMN, $colnum);
1260 ?array $types =
null,
1263 $type = match ($fetchmode) {
1266 default => PDO::FETCH_ASSOC,
1269 return $this->pdo->query($query, $type)->fetch();
1274 return $this->pdo->query(
'SELECT VERSION()')->fetchColumn();
1277 public function escape(
string $value,
bool $escape_wildcards =
false): string
1318 $fd = $this->getFieldDefinition();
1320 return $fd->checkIndexName($name);
1330 assert(is_array($fields));
1331 $manager = $this->manager;
1334 if (!$this->checkIndexName($name)) {
1335 throw new ilDatabaseException(
"ilDB Error: addUniqueConstraint(" . $table .
"," . $name .
")");
1338 $fields_corrected = [];
1339 foreach ($fields as
$f) {
1340 $fields_corrected[
$f] = [];
1344 'fields' => $fields_corrected,
1347 return $manager->
createConstraint($table, $this->constraintName($table, $name), $definition);
1352 return $this->manager->dropConstraint($table, $this->constraintName($table, $name),
false);
1358 $cons = $analyzer->getConstraintsInformation($table);
1359 foreach ($cons as
$c) {
1360 if (
$c[
"type"] ===
"unique" && count($fields) === count(
$c[
"fields"])) {
1362 foreach ($fields as
$f) {
1363 if (!isset(
$c[
"fields"][
$f])) {
1368 return $this->dropUniqueConstraint($table,
$c[
'name']);
1378 return (
int) $this->pdo->lastInsertId();
1389 $cons = $analyzer->getConstraintsInformation($table);
1390 foreach ($cons as
$c) {
1391 if (
$c[
"type"] ===
"unique" && count($fields) === count(
$c[
"fields"])) {
1393 foreach ($fields as
$f) {
1394 if (!isset(
$c[
"fields"][
$f])) {
1409 return $this->manager->dropConstraint($table_name,
"PRIMARY",
true);
1414 foreach (
$data as $set) {
1415 $this->execute($stmt, $set);
1422 return "FROM_UNIXTIME(" . $expr .
")";
1427 return "UNIX_TIMESTAMP()";
1436 $d = $this->fetchObject($this->query(
"SELECT VERSION() AS version"));
1438 if (
$d !==
null &&
$d->version) {
1449 if (!$this->doesCollationSupportMB4Strings()) {
1450 $query_replaced = preg_replace(
1451 '/[\x{10000}-\x{10FFFF}]/u',
1455 if (!empty($query_replaced)) {
1456 return $query_replaced;
1474 public function groupConcat(
string $a_field_name,
string $a_seperator =
",", ?
string $a_order =
null): string
1476 return $this->manager->getQueryUtils()->groupConcat($a_field_name, $a_seperator, $a_order);
1482 public function cast(
string $a_field_name,
string $a_dest_type): string
1484 return $this->manager->getQueryUtils()->cast($a_field_name, $a_dest_type);
1488 string $foreign_key_name,
1491 array $reference_field_names,
1492 string $reference_table,
1496 return $this->manager->addForeignKey($foreign_key_name, $field_names, $table_name, $reference_field_names, $reference_table, $on_update, $on_delete);
1501 return $this->manager->dropForeignKey($foreign_key_name, $table_name);
1506 return $this->manager->foreignKeyExists($foreign_key_name, $table_name);
1516 $constraints = $this->manager->listTableConstraints($table_name);
1518 if (in_array(
'primary', $constraints)) {
1519 $definitions = $this->reverse->getTableConstraintDefinition($table_name,
'primary');
1520 $primary_fields = array_keys($definitions[
'fields']);
1521 sort($primary_fields);
1524 return $primary_fields === $fields;
This class gives all kind of DB information using the database manager and reverse module.
const MYSQL_ENGINE_INNODB
const MYSQL_COLLATION_UTF8MB4
Class ilDBPdoFieldDefinition.
createConstraint(string $table, string $name, array $definition)
Class ilDBPdoMySQLFieldDefinition.
renameTable(string $name, string $new_name)
fetchAll(ilDBStatement $statement, int $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
addForeignKey(string $foreign_key_name, array $field_names, string $table_name, array $reference_field_names, string $reference_table, ?ForeignKeyConstraints $on_update=null, ?ForeignKeyConstraints $on_delete=null)
setUsername(string $username)
dropUniqueConstraintByFields(string $table, array $fields)
checkColumnName(string $a_name)
setLimit(int $limit, int $offset=0)
Set the Limit for the next Query.
createTable(string $table_name, array $fields, bool $drop_table=false, bool $ignore_erros=false)
in(string $field, array $values, bool $negate=false, string $type="")
tableExists(string $table_name)
manipulateF(string $query, array $types, array $values)
dropTable(string $table_name, bool $error_if_not_existing=true)
sanitizeMB4StringIfNotSupported(string $query)
string sanitized query
isFulltextIndex(string $a_table, string $a_name)
Is index a fulltext index?
numRows(ilDBStatement $statement)
setStorageEngine(string $storage_engine)
escapePattern(string $text)
free(ilDBStatement $a_st)
connect(bool $return_false_for_error=false)
insert(string $table_name, array $values)
fromUnixtime(string $expr, bool $to_text=true)
groupConcat(string $a_field_name, string $a_seperator=",", ?string $a_order=null)
enableResultBuffering(bool $a_status)
checkIndexName(string $name)
dropIndex(string $a_table, string $a_name="i1")
addPrimaryKey(string $table_name, array $primary_keys)
dropForeignKey(string $foreign_key_name, string $table_name)
substr(string $a_exp, int $a_pos=1, int $a_len=-1)
queryF(string $query, array $types, array $values)
supportsEngineMigration()
getPrimaryKeyIdentifier()
executeMultiple(ilDBStatement $stmt, array $data)
getAllowedAttributes()
string[]
checkTableName(string $a_name)
setDBPassword(string $password)
addFulltextIndex(string $table, array $fields, string $a_name="in")
sequenceExists(string $sequence)
escape(string $value, bool $escape_wildcards=false)
getServerVersion(bool $native=false)
modifyTableColumn(string $table, string $column, array $attributes)
addUniqueConstraint(string $table, array $fields, string $name="con")
migrateAllTablesToCollation(string $collation=ilDBConstants::MYSQL_COLLATION_UTF8MB4)
@inheritDoc
setCharset(string $charset)
dropFulltextIndex(string $a_table, string $a_name)
Drop fulltext index.
getAdditionalAttributes()
dropUniqueConstraint(string $table, string $name="con")
addIndex(string $table_name, array $fields, string $index_name='', bool $fulltext=false)
getSequenceName(string $table_name)
setFieldDefinition(\ilDBPdoFieldDefinition $field_definition)
createSequence(string $table_name, int $start=1)
dropPrimaryKey(string $table_name)
supportsCollationMigration()
@inheritDoc
appendLimit(string $query)
prepareManip(string $query, ?array $types=null)
loadModule(string $module)
queryCol(string $query, int $type=PDO::FETCH_ASSOC, int $colnum=0)
setDbname(string $dbname)
indexExistsByFields(string $table_name, array $fields)
concat(array $values, bool $allow_null=true)
renameTableColumn(string $table_name, string $column_old_name, string $column_new_name)
equals(string $columns, $value, string $type, bool $emptyOrNull=false)
lockTables(array $tables)
checkColumn(string $a_col, array $a_def)
migrateAllTablesToEngine(string $engine=ilDBConstants::MYSQL_ENGINE_INNODB)
primaryExistsByFields(string $table_name, array $fields)
prepare(string $query, ?array $types=null, ?array $result_types=null)
Prepare a query (SELECT) statement to be used with execute.
ilDBPdoFieldDefinition $field_definition
like(string $column, string $type, string $value="?", bool $case_insensitive=true)
dropIndexByFields(string $table_name, array $fields)
quoteIdentifier(string $identifier, bool $check_option=false)
doesCollationSupportMB4Strings()
@inheritDoc
const FEATURE_TRANSACTIONS
dropTableColumn(string $table_name, string $column_name)
createDatabase(string $a_name, string $a_charset="utf8", string $a_collation="")
getIndexName(string $index_name_base)
manipulate(string $query)
addTableColumn(string $table_name, string $column_name, array $attributes)
constraintName(string $a_table, string $a_constraint)
Determine contraint name by table name and constraint name.
useSlave(bool $bool)
TODO.
fetchAssoc(ilDBStatement $statement)
checkTableColumns(array $a_cols)
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.
locate(string $needle, string $string, int $start_pos=1)
checkColumnDefinition(array $a_def, bool $a_modify_mode=false)
upper(string $expression)
foreignKeyExists(string $foreign_key_name, string $table_name)
dropSequence(string $table_name)
uniqueConstraintExists(string $table, array $fields)
nextId(string $table_name)
cast(string $a_field_name, string $a_dest_type)
fetchObject(ilDBStatement $query_result)
update(string $table_name, array $columns, array $where)
@description $where MUST contain existing columns only.
static isReservedWord(string $a_word)
supports(string $feature)
setPassword(string $password)
tableColumnExists(string $table_name, string $column_name)
queryRow(string $query, ?array $types=null, int $fetchmode=ilDBConstants::FETCHMODE_DEFAULT)
initFromIniFile(?ilIniFile $ini=null)
quote($value, ?string $type=null)
lower(string $expression)
Class ilDatabaseException.
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
Class ilPDOStatement is a Wrapper Class for PDOStatement.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilAtomQuery Use ilAtomQuery to fire Database-Actions which have to be done without beeing i...
Interface ilDBPdoInterface.
execute(?array $a_data=null)
fetch(int $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
if(!file_exists('../ilias.ini.php'))