ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilDBPdo Class Reference

Class pdoDB. More...

+ Inheritance diagram for ilDBPdo:
+ Collaboration diagram for ilDBPdo:

Public Member Functions

 connect (bool $return_false_for_error=false)
 
 initHelpers ()
 
 getFieldDefinition ()
 
 setFieldDefinition (\ilDBPdoFieldDefinition $field_definition)
 
 createDatabase (string $a_name, string $a_charset="utf8", string $a_collation="")
 
 getLastErrorCode ()
 
 initFromIniFile (?ilIniFile $ini=null)
 
 generateDSN ()
 
 quoteIdentifier (string $identifier, bool $check_option=false)
 
 nextId (string $table_name)
 
 createTable (string $table_name, array $fields, bool $drop_table=false, bool $ignore_erros=false)
 
 checkColumnName (string $a_name)
 
 addPrimaryKey (string $table_name, array $primary_keys)
 
 dropIndexByFields (string $table_name, array $fields)
 
 getPrimaryKeyIdentifier ()
 
 createSequence (string $table_name, int $start=1)
 
 tableExists (string $table_name)
 
 tableColumnExists (string $table_name, string $column_name)
 
 addTableColumn (string $table_name, string $column_name, array $attributes)
 
 dropTable (string $table_name, bool $error_if_not_existing=true)
 
 query (string $query)
 
 fetchAll (ilDBStatement $statement, int $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
 
 dropSequence (string $table_name)
 
 dropTableColumn (string $table_name, string $column_name)
 
 renameTableColumn (string $table_name, string $column_old_name, string $column_new_name)
 
 insert (string $table_name, array $values)
 
 fetchObject (ilDBStatement $query_result)
 
 update (string $table_name, array $columns, array $where)
 $where MUST contain existing columns only. More...
 
 manipulate (string $query)
 
 fetchAssoc (ilDBStatement $statement)
 
 numRows (ilDBStatement $statement)
 
 quote ($value, ?string $type=null)
 
 indexExistsByFields (string $table_name, array $fields)
 
 addIndex (string $table_name, array $fields, string $index_name='', bool $fulltext=false)
 
 addFulltextIndex (string $table, array $fields, string $a_name="in")
 
 dropFulltextIndex (string $a_table, string $a_name)
 Drop fulltext index. More...
 
 isFulltextIndex (string $a_table, string $a_name)
 Is index a fulltext index? More...
 
 getIndexName (string $index_name_base)
 
 getSequenceName (string $table_name)
 
 constraintName (string $a_table, string $a_constraint)
 Determine contraint name by table name and constraint name. More...
 
 getDSN ()
 Get DSN. More...
 
 getDBType ()
 Get DSN. More...
 
 setDBType (string $type)
 
 lockTables (array $tables)
 
 unlockTables ()
 
 in (string $field, array $values, bool $negate=false, string $type="")
 
 queryF (string $query, array $types, array $values)
 
 manipulateF (string $query, array $types, array $values)
 
 useSlave (bool $bool)
 TODO. More...
 
 setLimit (int $limit, int $offset=0)
 Set the Limit for the next Query. More...
 
 like (string $column, string $type, string $value="?", bool $case_insensitive=true)
 
 now ()
 
 replace (string $table, array $primary_keys, array $other_columns)
 Replace into method. More...
 
 equals (string $columns, $value, string $type, bool $emptyOrNull=false)
 
 getHost ()
 
 setHost (string $host)
 
 getDbname ()
 
 setDbname (string $dbname)
 
 getCharset ()
 
 setCharset (string $charset)
 
 getUsername ()
 
 setUsername (string $username)
 
 getPassword ()
 
 setPassword (string $password)
 
 getPort ()
 
 setPort (int $port)
 
 setDBUser (string $user)
 
 setDBPort (int $port)
 
 setDBPassword (string $password)
 
 setDBHost (string $host)
 
 upper (string $expression)
 
 lower (string $expression)
 
 substr (string $a_exp, int $a_pos=1, int $a_len=-1)
 
 prepareManip (string $query, ?array $types=null)
 
 prepare (string $query, ?array $types=null, ?array $result_types=null)
 
 enableResultBuffering (bool $a_status)
 
 supportsSlave ()
 
 supportsFulltext ()
 
 supportsTransactions ()
 
 supports (string $feature)
 
 listTables ()
 
 loadModule (string $module)
 
 getAllowedAttributes ()
 
Returns
string[]
More...
 
 sequenceExists (string $sequence)
 
 listSequences ()
 
 concat (array $values, bool $allow_null=true)
 
 locate (string $needle, string $string, int $start_pos=1)
 
 modifyTableColumn (string $table, string $column, array $attributes)
 
 free (ilDBStatement $a_st)
 
 renameTable (string $name, string $new_name)
 
 checkTableName (string $a_name)
 
 beginTransaction ()
 
 commit ()
 
 rollback ()
 
 dropIndex (string $a_table, string $a_name="i1")
 
 setStorageEngine (string $storage_engine)
 
 getStorageEngine ()
 
 queryCol (string $query, int $type=PDO::FETCH_ASSOC, int $colnum=0)
 
 queryRow (string $query, ?array $types=null, int $fetchmode=ilDBConstants::FETCHMODE_DEFAULT)
 
 getServerVersion (bool $native=false)
 
 escape (string $value, bool $escape_wildcards=false)
 
 escapePattern (string $text)
 
 migrateAllTablesToEngine (string $engine=ilDBConstants::MYSQL_ENGINE_INNODB)
 
 migrateAllTablesToCollation (string $collation=ilDBConstants::MYSQL_COLLATION_UTF8MB4)
 
 supportsCollationMigration ()
 
 supportsEngineMigration ()
 
 checkIndexName (string $name)
 
 addUniqueConstraint (string $table, array $fields, string $name="con")
 
 dropUniqueConstraint (string $table, string $name="con")
 
 dropUniqueConstraintByFields (string $table, array $fields)
 
 getLastInsertId ()
 
 buildAtomQuery ()
 
 uniqueConstraintExists (string $table, array $fields)
 
 dropPrimaryKey (string $table_name)
 
 executeMultiple (ilDBStatement $stmt, array $data)
 
 fromUnixtime (string $expr, bool $to_text=true)
 
 unixTimestamp ()
 
 getDBVersion ()
 
 sanitizeMB4StringIfNotSupported (string $query)
 
Parameters
$querystring to sanitize, all MB4-Characters like emojis will re replaced with ???
Returns
string sanitized query
More...
 
 doesCollationSupportMB4Strings ()
 
 groupConcat (string $a_field_name, string $a_seperator=",", ?string $a_order=null)
 
 cast (string $a_field_name, string $a_dest_type)
 
 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)
 
 dropForeignKey (string $foreign_key_name, string $table_name)
 
 foreignKeyExists (string $foreign_key_name, string $table_name)
 
 buildIntegrityAnalyser ()
 
 primaryExistsByFields (string $table_name, array $fields)
 
- Public Member Functions inherited from ilDBInterface
 quote ($value, string $type)
 
 substr (string $expression)
 
 prepare (string $a_query, array $a_types=null, array $a_result_types=null)
 Prepare a query (SELECT) statement to be used with execute. More...
 
 execute (ilDBStatement $stmt, array $data=[])
 
- Public Member Functions inherited from ilDBPdoInterface
 migrateTableToEngine (string $table_name, string $engine=ilDBConstants::MYSQL_ENGINE_INNODB)
 
 migrateTableCollation (string $table_name, string $collation=ilDBConstants::MYSQL_COLLATION_UTF8MB4)
 

Static Public Member Functions

static isReservedWord (string $a_word)
 
- Static Public Member Functions inherited from ilDBInterface
static getReservedWords ()
 Get reserved words. More...
 

Data Fields

array $options = []
 
const FEATURE_TRANSACTIONS = 'transactions'
 
const FEATURE_FULLTEXT = 'fulltext'
 
const FEATURE_SLAVE = 'slave'
 

Protected Member Functions

 initSQLMode ()
 
 getAttributes ()
 
 getAdditionalAttributes ()
 
 checkTableColumns (array $a_cols)
 
 checkColumn (string $a_col, array $a_def)
 
 checkColumnDefinition (array $a_def, bool $a_modify_mode=false)
 
 appendLimit (string $query)
 

Protected Attributes

string $host = ''
 
string $dbname = ''
 
string $charset = 'utf8'
 
string $username = ''
 
string $password = ''
 
int $port = 3306
 
PDO $pdo = null
 
ilDBPdoManager $manager
 
ilDBPdoReverse $reverse
 
int $limit = null
 
int $offset = null
 
string $storage_engine = 'InnoDB'
 
string $dsn = ''
 
array $attributes
 
string $db_type = ''
 
int $error_code = 0
 
ilDBPdoFieldDefinition $field_definition = null
 

Detailed Description

Member Function Documentation

◆ addForeignKey()

ilDBPdo::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 
)
Parameters
string[]$field_names
string[]$reference_field_names

Implements ilDBInterface.

Definition at line 1508 of file class.ilDBPdo.php.

1516  : bool {
1517  return $this->manager->addForeignKey($foreign_key_name, $field_names, $table_name, $reference_field_names, $reference_table, $on_update, $on_delete);
1518  }

◆ addFulltextIndex()

ilDBPdo::addFulltextIndex ( string  $table,
array  $fields,
string  $a_name = "in" 
)
Exceptions

Implements ilDBInterface.

Definition at line 663 of file class.ilDBPdo.php.

References $q, constraintName(), and query().

Referenced by addIndex().

663  : bool
664  {
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)";
668  $this->query($q);
669  return true;
670  }
query(string $query)
constraintName(string $a_table, string $a_constraint)
Determine contraint name by table name and constraint name.
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addIndex()

ilDBPdo::addIndex ( string  $table_name,
array  $fields,
string  $index_name = '',
bool  $fulltext = false 
)

Implements ilDBInterface.

Definition at line 637 of file class.ilDBPdo.php.

References Vendor\Package\$f, addFulltextIndex(), constraintName(), and supportsFulltext().

637  : bool
638  {
639  assert(is_array($fields));
640  $this->field_definition->checkIndexName($index_name);
641 
642  $definition_fields = array();
643  foreach ($fields as $f) {
644  $definition_fields[$f] = array();
645  }
646  $definition = array(
647  'fields' => $definition_fields,
648  );
649 
650  if (!$fulltext) {
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);
654  // TODO
655  }
656 
657  return true;
658  }
constraintName(string $a_table, string $a_constraint)
Determine contraint name by table name and constraint name.
addFulltextIndex(string $table, array $fields, string $a_name="in")
+ Here is the call graph for this function:

◆ addPrimaryKey()

ilDBPdo::addPrimaryKey ( string  $table_name,
array  $primary_keys 
)
Exceptions

Implements ilDBInterface.

Definition at line 236 of file class.ilDBPdo.php.

References Vendor\Package\$f, constraintName(), and getPrimaryKeyIdentifier().

236  : bool
237  {
238  assert(is_array($primary_keys));
239 
240  $fields = array();
241  foreach ($primary_keys as $f) {
242  $fields[$f] = array();
243  }
244  $definition = array(
245  'primary' => true,
246  'fields' => $fields,
247  );
248  $this->manager->createConstraint(
249  $table_name,
250  $this->constraintName($table_name, $this->getPrimaryKeyIdentifier()),
251  $definition
252  );
253 
254  return true;
255  }
constraintName(string $a_table, string $a_constraint)
Determine contraint name by table name and constraint name.
getPrimaryKeyIdentifier()
+ Here is the call graph for this function:

◆ addTableColumn()

ilDBPdo::addTableColumn ( string  $table_name,
string  $column_name,
array  $attributes 
)
Exceptions

Implements ilDBInterface.

Definition at line 305 of file class.ilDBPdo.php.

References checkColumnDefinition(), and checkColumnName().

305  : bool
306  {
307  if (!$this->checkColumnName($column_name)) {
308  throw new ilDatabaseException("ilDB Error: addTableColumn(" . $table_name . ", " . $column_name . ")");
309  }
310  if (!$this->checkColumnDefinition($attributes)) {
311  throw new ilDatabaseException("ilDB Error: addTableColumn(" . $table_name . ", " . $column_name . ")");
312  }
313 
314  $changes = array(
315  "add" => array(
316  $column_name => $attributes,
317  ),
318  );
319 
320  return $this->manager->alterTable($table_name, $changes, false);
321  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkColumnDefinition(array $a_def, bool $a_modify_mode=false)
array $attributes
checkColumnName(string $a_name)
+ Here is the call graph for this function:

◆ addUniqueConstraint()

ilDBPdo::addUniqueConstraint ( string  $table,
array  $fields,
string  $name = "con" 
)
Exceptions

Implements ilDBPdoInterface.

Definition at line 1349 of file class.ilDBPdo.php.

References Vendor\Package\$f, $manager, checkIndexName(), constraintName(), and ilDBPdoManager\createConstraint().

1349  : bool
1350  {
1351  assert(is_array($fields));
1353 
1354  // check index name
1355  if (!$this->checkIndexName($name)) {
1356  throw new ilDatabaseException("ilDB Error: addUniqueConstraint(" . $table . "," . $name . ")");
1357  }
1358 
1359  $fields_corrected = array();
1360  foreach ($fields as $f) {
1361  $fields_corrected[$f] = array();
1362  }
1363  $definition = array(
1364  'unique' => true,
1365  'fields' => $fields_corrected,
1366  );
1367 
1368  return $manager->createConstraint($table, $this->constraintName($table, $name), $definition);
1369  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
constraintName(string $a_table, string $a_constraint)
Determine contraint name by table name and constraint name.
ilDBPdoManager $manager
checkIndexName(string $name)
createConstraint(string $table, string $name, array $definition)
+ Here is the call graph for this function:

◆ appendLimit()

ilDBPdo::appendLimit ( string  $query)
protected

Definition at line 1092 of file class.ilDBPdo.php.

References $limit.

Referenced by query().

1092  : string
1093  {
1094  if ($this->limit !== null && $this->offset !== null) {
1095  $query .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
1096  $this->limit = null;
1097  $this->offset = null;
1098 
1099  return $query;
1100  }
1101 
1102  return $query;
1103  }
+ Here is the caller graph for this function:

◆ beginTransaction()

ilDBPdo::beginTransaction ( )
Exceptions

Implements ilDBInterface.

Definition at line 1208 of file class.ilDBPdo.php.

References supports().

1208  : bool
1209  {
1210  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1211  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1212  }
1213 
1214  return $this->pdo->beginTransaction();
1215  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
supports(string $feature)
+ Here is the call graph for this function:

◆ buildAtomQuery()

ilDBPdo::buildAtomQuery ( )

Implements ilDBInterface.

Definition at line 1402 of file class.ilDBPdo.php.

1402  : ilAtomQuery
1403  {
1404  return new ilAtomQueryLock($this);
1405  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ buildIntegrityAnalyser()

ilDBPdo::buildIntegrityAnalyser ( )

Implements ilDBInterface.

Definition at line 1530 of file class.ilDBPdo.php.

1530  : Integrity
1531  {
1532  return new Integrity($this);
1533  }

◆ cast()

ilDBPdo::cast ( string  $a_field_name,
string  $a_dest_type 
)

Implements ilDBInterface.

Definition at line 1503 of file class.ilDBPdo.php.

1503  : string
1504  {
1505  return $this->manager->getQueryUtils()->cast($a_field_name, $a_dest_type);
1506  }

◆ checkColumn()

ilDBPdo::checkColumn ( string  $a_col,
array  $a_def 
)
protected

Definition at line 215 of file class.ilDBPdo.php.

References checkColumnDefinition(), and checkColumnName().

Referenced by checkTableColumns().

215  : bool
216  {
217  if (!$this->checkColumnName($a_col)) {
218  return false;
219  }
220  return $this->checkColumnDefinition($a_def);
221  }
checkColumnDefinition(array $a_def, bool $a_modify_mode=false)
checkColumnName(string $a_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkColumnDefinition()

ilDBPdo::checkColumnDefinition ( array  $a_def,
bool  $a_modify_mode = false 
)
protected

Definition at line 223 of file class.ilDBPdo.php.

Referenced by addTableColumn(), checkColumn(), and modifyTableColumn().

223  : bool
224  {
225  return $this->field_definition->checkColumnDefinition($a_def);
226  }
+ Here is the caller graph for this function:

◆ checkColumnName()

ilDBPdo::checkColumnName ( string  $a_name)

Definition at line 228 of file class.ilDBPdo.php.

Referenced by addTableColumn(), checkColumn(), and renameTableColumn().

228  : bool
229  {
230  return $this->field_definition->checkColumnName($a_name);
231  }
+ Here is the caller graph for this function:

◆ checkIndexName()

ilDBPdo::checkIndexName ( string  $name)
Exceptions

Implements ilDBPdoInterface.

Definition at line 1337 of file class.ilDBPdo.php.

References getFieldDefinition().

Referenced by addUniqueConstraint().

1337  : bool
1338  {
1339  $fd = $this->getFieldDefinition();
1340  if ($fd !== null) {
1341  return $fd->checkIndexName($name);
1342  }
1343  return false;
1344  }
getFieldDefinition()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTableColumns()

ilDBPdo::checkTableColumns ( array  $a_cols)
protected

Definition at line 204 of file class.ilDBPdo.php.

References checkColumn().

Referenced by createTable().

204  : bool
205  {
206  foreach ($a_cols as $col => $def) {
207  if (!$this->checkColumn($col, $def)) {
208  return false;
209  }
210  }
211 
212  return true;
213  }
checkColumn(string $a_col, array $a_def)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTableName()

ilDBPdo::checkTableName ( string  $a_name)
Exceptions

Implements ilDBInterface.

Definition at line 1194 of file class.ilDBPdo.php.

Referenced by createTable(), and renameTable().

1194  : bool
1195  {
1196  return $this->field_definition->checkTableName($a_name);
1197  }
+ Here is the caller graph for this function:

◆ commit()

ilDBPdo::commit ( )
Exceptions

Implements ilDBInterface.

Definition at line 1220 of file class.ilDBPdo.php.

References supports().

1220  : bool
1221  {
1222  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1223  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1224  }
1225 
1226  return $this->pdo->commit();
1227  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
supports(string $feature)
+ Here is the call graph for this function:

◆ concat()

ilDBPdo::concat ( array  $values,
bool  $allow_null = true 
)

Implements ilDBInterface.

Definition at line 1087 of file class.ilDBPdo.php.

1087  : string
1088  {
1089  return $this->manager->getQueryUtils()->concat($values, $allow_null);
1090  }

◆ connect()

ilDBPdo::connect ( bool  $return_false_for_error = false)
Exceptions

Implements ilDBInterface.

Definition at line 62 of file class.ilDBPdo.php.

References Vendor\Package\$e, generateDSN(), getAttributes(), getDSN(), getPassword(), getUsername(), initHelpers(), and initSQLMode().

Referenced by createDatabase().

62  : ?bool
63  {
64  $this->generateDSN();
65  try {
66  $options = $this->getAttributes();
67  $this->pdo = new PDO($this->getDSN(), $this->getUsername(), $this->getPassword(), $options);
68  $this->initHelpers();
69  $this->initSQLMode();
70  } catch (Exception $e) {
71  $this->error_code = $e->getCode();
72  if ($return_false_for_error) {
73  return false;
74  }
75  throw $e;
76  }
77 
78  return ($this->pdo->errorCode() === PDO::ERR_NONE);
79  }
initHelpers()
getDSN()
Get DSN.
array $options
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constraintName()

ilDBPdo::constraintName ( string  $a_table,
string  $a_constraint 
)

Determine contraint name by table name and constraint name.

In MySQL these are "unique" per table

Implements ilDBInterface.

Definition at line 711 of file class.ilDBPdo.php.

Referenced by addFulltextIndex(), addIndex(), addPrimaryKey(), addUniqueConstraint(), dropFulltextIndex(), and dropUniqueConstraint().

711  : string
712  {
713  return $a_constraint;
714  }
+ Here is the caller graph for this function:

◆ createDatabase()

ilDBPdo::createDatabase ( string  $a_name,
string  $a_charset = "utf8",
string  $a_collation = "" 
)

Implements ilDBInterface.

Definition at line 112 of file class.ilDBPdo.php.

References Vendor\Package\$e, connect(), generateDSN(), query(), and setDbname().

112  : bool
113  {
114  $this->setDbname('');
115  $this->generateDSN();
116  $this->connect(true);
117  try {
118  $this->query($this->manager->getQueryUtils()->createDatabase($a_name, $a_charset, $a_collation));
119  return true;
120  } catch (PDOException $e) {
121  return false;
122  }
123  }
query(string $query)
setDbname(string $dbname)
connect(bool $return_false_for_error=false)
+ Here is the call graph for this function:

◆ createSequence()

ilDBPdo::createSequence ( string  $table_name,
int  $start = 1 
)

Implements ilDBInterface.

Definition at line 279 of file class.ilDBPdo.php.

279  : bool
280  {
281  $this->manager->createSequence($table_name, $start);
282  return true;
283  }

◆ createTable()

ilDBPdo::createTable ( string  $table_name,
array  $fields,
bool  $drop_table = false,
bool  $ignore_erros = false 
)
Exceptions

Implements ilDBInterface.

Definition at line 181 of file class.ilDBPdo.php.

References checkTableColumns(), checkTableName(), and dropTable().

186  : bool {
187  // check table name
188  if (!$ignore_erros && !$this->checkTableName($table_name)) {
189  throw new ilDatabaseException("ilDB Error: createTable(" . $table_name . ")");
190  }
191 
192  // check definition array
193  if (!$ignore_erros && !$this->checkTableColumns($fields)) {
194  throw new ilDatabaseException("ilDB Error: createTable(" . $table_name . ")");
195  }
196 
197  if ($drop_table) {
198  $this->dropTable($table_name, false);
199  }
200 
201  return $this->manager->createTable($table_name, $fields, array());
202  }
checkTableColumns(array $a_cols)
checkTableName(string $a_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
dropTable(string $table_name, bool $error_if_not_existing=true)
+ Here is the call graph for this function:

◆ doesCollationSupportMB4Strings()

ilDBPdo::doesCollationSupportMB4Strings ( )

Implements ilDBInterface.

Definition at line 1487 of file class.ilDBPdo.php.

Referenced by sanitizeMB4StringIfNotSupported().

1487  : bool
1488  {
1489  return false;
1490  }
+ Here is the caller graph for this function:

◆ dropForeignKey()

ilDBPdo::dropForeignKey ( string  $foreign_key_name,
string  $table_name 
)

Implements ilDBInterface.

Definition at line 1520 of file class.ilDBPdo.php.

1520  : bool
1521  {
1522  return $this->manager->dropForeignKey($foreign_key_name, $table_name);
1523  }

◆ dropFulltextIndex()

ilDBPdo::dropFulltextIndex ( string  $a_table,
string  $a_name 
)

Drop fulltext index.

Implements ilDBInterface.

Definition at line 675 of file class.ilDBPdo.php.

References constraintName(), and query().

675  : bool
676  {
677  $i_name = $this->constraintName($a_table, $a_name) . "_idx";
678  $this->query("ALTER TABLE $a_table DROP FULLTEXT $i_name");
679  return true;
680  }
query(string $query)
constraintName(string $a_table, string $a_constraint)
Determine contraint name by table name and constraint name.
+ Here is the call graph for this function:

◆ dropIndex()

ilDBPdo::dropIndex ( string  $a_table,
string  $a_name = "i1" 
)

Implements ilDBInterface.

Definition at line 1241 of file class.ilDBPdo.php.

Referenced by dropIndexByFields().

1241  : bool
1242  {
1243  return $this->manager->dropIndex($a_table, $a_name);
1244  }
+ Here is the caller graph for this function:

◆ dropIndexByFields()

ilDBPdo::dropIndexByFields ( string  $table_name,
array  $fields 
)
Exceptions

Implements ilDBInterface.

Definition at line 260 of file class.ilDBPdo.php.

References dropIndex().

260  : bool
261  {
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']);
265 
266  if ($idx_fields === $fields) {
267  return $this->dropIndex($table_name, $idx_name);
268  }
269  }
270 
271  return false;
272  }
dropIndex(string $a_table, string $a_name="i1")
+ Here is the call graph for this function:

◆ dropPrimaryKey()

ilDBPdo::dropPrimaryKey ( string  $table_name)

Implements ilDBPdoInterface.

Definition at line 1428 of file class.ilDBPdo.php.

1428  : bool
1429  {
1430  return $this->manager->dropConstraint($table_name, "PRIMARY", true);
1431  }

◆ dropSequence()

ilDBPdo::dropSequence ( string  $table_name)

Implements ilDBInterface.

Definition at line 391 of file class.ilDBPdo.php.

391  : bool
392  {
393  $this->manager->dropSequence($table_name);
394  return true;
395  }

◆ dropTable()

ilDBPdo::dropTable ( string  $table_name,
bool  $error_if_not_existing = true 
)
Exceptions

Implements ilDBInterface.

Definition at line 326 of file class.ilDBPdo.php.

References loadModule(), and ilDBConstants\MODULE_MANAGER.

Referenced by createTable().

326  : bool
327  {
328  $ilDBPdoManager = $this->loadModule(ilDBConstants::MODULE_MANAGER);
329  $tables = $ilDBPdoManager->listTables();
330  $table_exists = in_array($table_name, $tables);
331  if (!$table_exists && $error_if_not_existing) {
332  throw new ilDatabaseException("Table $table_name does not exist");
333  }
334 
335  // drop sequence
336  $sequences = $ilDBPdoManager->listSequences();
337  if (in_array($table_name, $sequences)) {
338  $ilDBPdoManager->dropSequence($table_name);
339  }
340 
341  // drop table
342  if ($table_exists) {
343  $ilDBPdoManager->dropTable($table_name);
344  }
345 
346  return true;
347  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadModule(string $module)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dropTableColumn()

ilDBPdo::dropTableColumn ( string  $table_name,
string  $column_name 
)
Exceptions

Implements ilDBInterface.

Definition at line 400 of file class.ilDBPdo.php.

400  : bool
401  {
402  $changes = array(
403  "remove" => array(
404  $column_name => array(),
405  ),
406  );
407 
408  return $this->manager->alterTable($table_name, $changes, false);
409  }

◆ dropUniqueConstraint()

ilDBPdo::dropUniqueConstraint ( string  $table,
string  $name = "con" 
)

Implements ilDBPdoInterface.

Definition at line 1371 of file class.ilDBPdo.php.

References constraintName().

Referenced by dropUniqueConstraintByFields().

1371  : bool
1372  {
1373  return $this->manager->dropConstraint($table, $this->constraintName($table, $name), false);
1374  }
constraintName(string $a_table, string $a_constraint)
Determine contraint name by table name and constraint name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dropUniqueConstraintByFields()

ilDBPdo::dropUniqueConstraintByFields ( string  $table,
array  $fields 
)

Implements ilDBPdoInterface.

Definition at line 1376 of file class.ilDBPdo.php.

References Vendor\Package\$c, Vendor\Package\$f, and dropUniqueConstraint().

1376  : bool
1377  {
1378  $analyzer = new ilDBAnalyzer();
1379  $cons = $analyzer->getConstraintsInformation($table);
1380  foreach ($cons as $c) {
1381  if ($c["type"] === "unique" && count($fields) === count($c["fields"])) {
1382  $all_in = true;
1383  foreach ($fields as $f) {
1384  if (!isset($c["fields"][$f])) {
1385  $all_in = false;
1386  }
1387  }
1388  if ($all_in) {
1389  return $this->dropUniqueConstraint($table, $c['name']);
1390  }
1391  }
1392  }
1393 
1394  return false;
1395  }
dropUniqueConstraint(string $table, string $name="con")
This class gives all kind of DB information using the database manager and reverse module...
+ Here is the call graph for this function:

◆ enableResultBuffering()

ilDBPdo::enableResultBuffering ( bool  $a_status)

Implements ilDBInterface.

Definition at line 998 of file class.ilDBPdo.php.

References $data, ilDBStatement\execute(), and ilDBInterface\execute().

998  : void
999  {
1000  $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $a_status);
1001  }
+ Here is the call graph for this function:

◆ equals()

ilDBPdo::equals ( string  $columns,
  $value,
string  $type,
bool  $emptyOrNull = false 
)
Parameters
mixed$value

Implements ilDBInterface.

Definition at line 874 of file class.ilDBPdo.php.

References quote().

874  : string
875  {
876  if (!$emptyOrNull || $value != "") {
877  return $columns . " = " . $this->quote($value, $type);
878  }
879 
880  return "(" . $columns . " = '' OR $columns IS NULL)";
881  }
quote($value, ?string $type=null)
+ Here is the call graph for this function:

◆ escape()

ilDBPdo::escape ( string  $value,
bool  $escape_wildcards = false 
)

Implements ilDBPdoInterface.

Definition at line 1298 of file class.ilDBPdo.php.

1298  : string
1299  {
1300  return $value;
1301  }

◆ escapePattern()

ilDBPdo::escapePattern ( string  $text)

Implements ilDBPdoInterface.

Definition at line 1303 of file class.ilDBPdo.php.

1303  : string
1304  {
1305  return $text;
1306  }

◆ executeMultiple()

ilDBPdo::executeMultiple ( ilDBStatement  $stmt,
array  $data 
)
Parameters
ilDBStatement[]$stmt
Returns
string[]

Implements ilDBPdoInterface.

Definition at line 1433 of file class.ilDBPdo.php.

References ilDBInterface\execute().

1433  : array
1434  {
1435  foreach ($data as $set) {
1436  $this->execute($stmt, $set);
1437  }
1438  return [];
1439  }
execute(ilDBStatement $stmt, array $data=[])
+ Here is the call graph for this function:

◆ fetchAll()

ilDBPdo::fetchAll ( ilDBStatement  $statement,
int  $fetch_mode = ilDBConstants::FETCHMODE_ASSOC 
)

Implements ilDBInterface.

Definition at line 381 of file class.ilDBPdo.php.

References $data, and ilDBStatement\fetch().

381  : array
382  {
383  $return = [];
384  while ($data = $statement->fetch($fetch_mode)) {
385  $return[] = $data;
386  }
387 
388  return $return;
389  }
fetch(int $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
+ Here is the call graph for this function:

◆ fetchAssoc()

ilDBPdo::fetchAssoc ( ilDBStatement  $statement)

Implements ilDBInterface.

Definition at line 571 of file class.ilDBPdo.php.

References $res, and ilDBStatement\fetch().

Referenced by isFulltextIndex().

571  : ?array
572  {
573  $res = $statement->fetch(PDO::FETCH_ASSOC);
574  if ($res === null || $res === false) {
575  $statement->closeCursor();
576 
577  return null;
578  }
579 
580  return $res;
581  }
$res
Definition: ltiservices.php:69
fetch(int $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fetchObject()

ilDBPdo::fetchObject ( ilDBStatement  $query_result)

Implements ilDBInterface.

Definition at line 458 of file class.ilDBPdo.php.

References $res, and ilDBStatement\fetchObject().

Referenced by getDBVersion().

458  : ?stdClass
459  {
460  $res = $query_result->fetchObject();
461  if ($res === null) {
462  $query_result->closeCursor();
463 
464  return null;
465  }
466 
467  return $res;
468  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ foreignKeyExists()

ilDBPdo::foreignKeyExists ( string  $foreign_key_name,
string  $table_name 
)

Implements ilDBInterface.

Definition at line 1525 of file class.ilDBPdo.php.

1525  : bool
1526  {
1527  return $this->manager->foreignKeyExists($foreign_key_name, $table_name);
1528  }

◆ free()

ilDBPdo::free ( ilDBStatement  $a_st)

Implements ilDBInterface.

Definition at line 1155 of file class.ilDBPdo.php.

Referenced by update().

1155  : void
1156  {
1157  $a_st->closeCursor();
1158  }
+ Here is the caller graph for this function:

◆ fromUnixtime()

ilDBPdo::fromUnixtime ( string  $expr,
bool  $to_text = true 
)

Implements ilDBPdoInterface.

Definition at line 1441 of file class.ilDBPdo.php.

1441  : string
1442  {
1443  return "FROM_UNIXTIME(" . $expr . ")";
1444  }

◆ generateDSN()

ilDBPdo::generateDSN ( )

Definition at line 159 of file class.ilDBPdo.php.

References $charset, getCharset(), getDbname(), getHost(), and getPort().

Referenced by connect(), createDatabase(), and initFromIniFile().

160  {
161  $port = $this->getPort() !== 0 ? ";port=" . $this->getPort() : "";
162  $dbname = $this->getDbname() !== '' ? ';dbname=' . $this->getDbname() : '';
163  $host = $this->getHost();
164  $charset = ';charset=' . $this->getCharset();
165  $this->dsn = 'mysql:host=' . $host . $port . $dbname . $charset;
166  }
string $host
string $charset
string $dbname
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdditionalAttributes()

ilDBPdo::getAdditionalAttributes ( )
protected

Definition at line 97 of file class.ilDBPdo.php.

Referenced by getAttributes().

97  : array
98  {
99  return array();
100  }
+ Here is the caller graph for this function:

◆ getAllowedAttributes()

ilDBPdo::getAllowedAttributes ( )

Returns
string[]

Implements ilDBInterface.

Definition at line 1072 of file class.ilDBPdo.php.

1072  : array
1073  {
1074  return $this->field_definition->getAllowedAttributes();
1075  }

◆ getAttributes()

ilDBPdo::getAttributes ( )
protected

Definition at line 87 of file class.ilDBPdo.php.

References $attributes, $options, and getAdditionalAttributes().

Referenced by connect().

87  : array
88  {
90  foreach ($this->getAdditionalAttributes() as $k => $v) {
91  $options[$k] = $v;
92  }
93 
94  return $options;
95  }
getAdditionalAttributes()
array $attributes
array $options
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCharset()

ilDBPdo::getCharset ( )

Definition at line 903 of file class.ilDBPdo.php.

References $charset.

Referenced by generateDSN().

903  : string
904  {
905  return $this->charset;
906  }
string $charset
+ Here is the caller graph for this function:

◆ getDbname()

ilDBPdo::getDbname ( )

Definition at line 893 of file class.ilDBPdo.php.

References $dbname.

Referenced by generateDSN().

893  : string
894  {
895  return $this->dbname;
896  }
string $dbname
+ Here is the caller graph for this function:

◆ getDBType()

ilDBPdo::getDBType ( )

Get DSN.

This must be overwritten in DBMS specific class.

Implements ilDBInterface.

Definition at line 721 of file class.ilDBPdo.php.

References $db_type.

721  : string
722  {
723  return $this->db_type;
724  }
string $db_type

◆ getDBVersion()

ilDBPdo::getDBVersion ( )
Exceptions
ilDatabaseException

Implements ilDBPdoInterface.

Definition at line 1455 of file class.ilDBPdo.php.

References Vendor\Package\$d, fetchObject(), and query().

1455  : string
1456  {
1457  $d = $this->fetchObject($this->query("SELECT VERSION() AS version"));
1458 
1459  if ($d !== null && $d->version) {
1460  return $d->version;
1461  }
1462  return 'Unknown';
1463  }
fetchObject(ilDBStatement $query_result)
query(string $query)
+ Here is the call graph for this function:

◆ getDSN()

ilDBPdo::getDSN ( )

Get DSN.

This must be overwritten in DBMS specific class.

Implements ilDBInterface.

Definition at line 716 of file class.ilDBPdo.php.

References $dsn.

Referenced by connect().

716  : string
717  {
718  return $this->dsn;
719  }
string $dsn
+ Here is the caller graph for this function:

◆ getFieldDefinition()

ilDBPdo::getFieldDefinition ( )

Definition at line 102 of file class.ilDBPdo.php.

References $field_definition.

Referenced by checkIndexName().

103  {
105  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilDBPdoFieldDefinition $field_definition
+ Here is the caller graph for this function:

◆ getHost()

ilDBPdo::getHost ( )

Definition at line 883 of file class.ilDBPdo.php.

References $host.

Referenced by generateDSN().

883  : string
884  {
885  return $this->host;
886  }
string $host
+ Here is the caller graph for this function:

◆ getIndexName()

ilDBPdo::getIndexName ( string  $index_name_base)

Definition at line 697 of file class.ilDBPdo.php.

References ilDBPdoFieldDefinition\INDEX_FORMAT.

697  : string
698  {
699  return sprintf(ilDBPdoFieldDefinition::INDEX_FORMAT, preg_replace('/[^a-z0-9_\$]/i', '_', $index_name_base));
700  }

◆ getLastErrorCode()

ilDBPdo::getLastErrorCode ( )
Returns
string|int|null

Definition at line 128 of file class.ilDBPdo.php.

References $error_code.

129  {
130  if ($this->pdo instanceof PDO) {
131  return $this->pdo->errorCode();
132  }
133 
134  return $this->error_code;
135  }
int $error_code

◆ getLastInsertId()

ilDBPdo::getLastInsertId ( )

Implements ilDBPdoInterface.

Definition at line 1397 of file class.ilDBPdo.php.

1397  : int
1398  {
1399  return (int) $this->pdo->lastInsertId();
1400  }

◆ getPassword()

ilDBPdo::getPassword ( )

Definition at line 923 of file class.ilDBPdo.php.

References $password.

Referenced by connect().

923  : string
924  {
925  return $this->password;
926  }
string $password
+ Here is the caller graph for this function:

◆ getPort()

ilDBPdo::getPort ( )

Definition at line 933 of file class.ilDBPdo.php.

References $port.

Referenced by generateDSN().

933  : int
934  {
935  return $this->port;
936  }
+ Here is the caller graph for this function:

◆ getPrimaryKeyIdentifier()

ilDBPdo::getPrimaryKeyIdentifier ( )

Implements ilDBInterface.

Definition at line 274 of file class.ilDBPdo.php.

Referenced by addPrimaryKey().

274  : string
275  {
276  return "PRIMARY";
277  }
+ Here is the caller graph for this function:

◆ getSequenceName()

ilDBPdo::getSequenceName ( string  $table_name)

Implements ilDBInterface.

Definition at line 702 of file class.ilDBPdo.php.

References ilDBPdoFieldDefinition\SEQUENCE_FORMAT.

Referenced by ilDBPdoMySQL\nextId(), and renameTable().

702  : string
703  {
704  return sprintf(ilDBPdoFieldDefinition::SEQUENCE_FORMAT, preg_replace('/[^a-z0-9_\$.]/i', '_', $table_name));
705  }
+ Here is the caller graph for this function:

◆ getServerVersion()

ilDBPdo::getServerVersion ( bool  $native = false)

Implements ilDBPdoInterface.

Definition at line 1293 of file class.ilDBPdo.php.

1293  : int
1294  {
1295  return $this->pdo->query('SELECT VERSION()')->fetchColumn();
1296  }

◆ getStorageEngine()

ilDBPdo::getStorageEngine ( )

Implements ilDBInterface.

Definition at line 1251 of file class.ilDBPdo.php.

References $storage_engine.

1251  : string
1252  {
1253  return $this->storage_engine;
1254  }
string $storage_engine

◆ getUsername()

ilDBPdo::getUsername ( )

Definition at line 913 of file class.ilDBPdo.php.

References $username.

Referenced by connect().

913  : string
914  {
915  return $this->username;
916  }
string $username
+ Here is the caller graph for this function:

◆ groupConcat()

ilDBPdo::groupConcat ( string  $a_field_name,
string  $a_seperator = ",",
?string  $a_order = null 
)

Implements ilDBInterface.

Definition at line 1495 of file class.ilDBPdo.php.

1495  : string
1496  {
1497  return $this->manager->getQueryUtils()->groupConcat($a_field_name, $a_seperator, $a_order);
1498  }

◆ in()

ilDBPdo::in ( string  $field,
array  $values,
bool  $negate = false,
string  $type = "" 
)

Implements ilDBInterface.

Definition at line 770 of file class.ilDBPdo.php.

770  : string
771  {
772  return $this->manager->getQueryUtils()->in($field, $values, $negate, $type);
773  }

◆ indexExistsByFields()

ilDBPdo::indexExistsByFields ( string  $table_name,
array  $fields 
)

Implements ilDBInterface.

Definition at line 623 of file class.ilDBPdo.php.

623  : bool
624  {
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']);
628 
629  if ($idx_fields === $fields) {
630  return true;
631  }
632  }
633 
634  return false;
635  }

◆ initFromIniFile()

ilDBPdo::initFromIniFile ( ?ilIniFile  $ini = null)

Implements ilDBInterface.

Definition at line 137 of file class.ilDBPdo.php.

References $DIC, $ini, generateDSN(), setDbname(), setDBType(), setHost(), setPassword(), setPort(), and setUsername().

137  : void
138  {
139  global $DIC;
140 
141  if ($ini instanceof ilIniFile) {
142  $clientIniFile = $ini;
143  } elseif ($DIC->offsetExists('ilClientIniFile')) {
144  $clientIniFile = $DIC['ilClientIniFile'];
145  } else {
146  throw new InvalidArgumentException('$tmpClientIniFile is not an instance of ilIniFile');
147  }
148 
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"));
155 
156  $this->generateDSN();
157  }
setHost(string $host)
setUsername(string $username)
setPassword(string $password)
global $DIC
Definition: feed.php:28
setDbname(string $dbname)
setPort(int $port)
setDBType(string $type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4
+ Here is the call graph for this function:

◆ initHelpers()

ilDBPdo::initHelpers ( )
abstract

Referenced by connect().

+ Here is the caller graph for this function:

◆ initSQLMode()

ilDBPdo::initSQLMode ( )
protected

Definition at line 83 of file class.ilDBPdo.php.

Referenced by connect().

83  : void
84  {
85  }
+ Here is the caller graph for this function:

◆ insert()

ilDBPdo::insert ( string  $table_name,
array  $values 
)
Returns
int The number of rows affected by the manipulation

Implements ilDBInterface.

Definition at line 441 of file class.ilDBPdo.php.

References ILIAS\LTI\ToolProvider\$key, quote(), quoteIdentifier(), and sanitizeMB4StringIfNotSupported().

441  : int
442  {
443  $real = array();
444  $fields = array();
445  foreach ($values as $key => $val) {
446  $real[] = $this->quote($val[1], $val[0]);
447  $fields[] = $this->quoteIdentifier($key);
448  }
449  $values_string = implode(",", $real);
450  $fields_string = implode(",", $fields);
451  $query = "INSERT INTO " . $this->quoteIdentifier($table_name) . " (" . $fields_string . ") VALUES (" . $values_string . ")";
452 
453  $query = $this->sanitizeMB4StringIfNotSupported($query);
454 
455  return (int) $this->pdo->exec($query);
456  }
quote($value, ?string $type=null)
string $key
Consumer key/client ID value.
Definition: System.php:193
quoteIdentifier(string $identifier, bool $check_option=false)
sanitizeMB4StringIfNotSupported(string $query)
string to sanitize, all MB4-Characters like emojis will re replaced with ??? string sanitized query ...
+ Here is the call graph for this function:

◆ isFulltextIndex()

ilDBPdo::isFulltextIndex ( string  $a_table,
string  $a_name 
)

Is index a fulltext index?

Implements ilDBInterface.

Definition at line 685 of file class.ilDBPdo.php.

References fetchAssoc(), and query().

685  : bool
686  {
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") {
690  return true;
691  }
692  }
693 
694  return false;
695  }
query(string $query)
fetchAssoc(ilDBStatement $statement)
+ Here is the call graph for this function:

◆ isReservedWord()

static ilDBPdo::isReservedWord ( string  $a_word)
static

Implements ilDBInterface.

Definition at line 1199 of file class.ilDBPdo.php.

References $DIC.

1199  : bool
1200  {
1201  global $DIC;
1202  return (new ilDBPdoMySQLFieldDefinition($DIC->database()))->isReserved($a_word);
1203  }
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ like()

ilDBPdo::like ( string  $column,
string  $type,
string  $value = "?",
bool  $case_insensitive = true 
)
Exceptions

Implements ilDBInterface.

Definition at line 831 of file class.ilDBPdo.php.

831  : string
832  {
833  return $this->manager->getQueryUtils()->like($column, $type, $value, $case_insensitive);
834  }

◆ listSequences()

ilDBPdo::listSequences ( )
Returns
string[]

Implements ilDBInterface.

Definition at line 1082 of file class.ilDBPdo.php.

Referenced by sequenceExists().

1082  : array
1083  {
1084  return $this->manager->listSequences();
1085  }
+ Here is the caller graph for this function:

◆ listTables()

ilDBPdo::listTables ( )
Returns
int[]|string[]

Implements ilDBInterface.

Definition at line 1050 of file class.ilDBPdo.php.

Referenced by ilDBPdoMySQL\migrateAllTablesToEngine().

1050  : array
1051  {
1052  return $this->manager->listTables();
1053  }
+ Here is the caller graph for this function:

◆ loadModule()

ilDBPdo::loadModule ( string  $module)
Returns
|

Implements ilDBInterface.

Definition at line 1058 of file class.ilDBPdo.php.

References $manager, $reverse, ilDBConstants\MODULE_MANAGER, and ilDBConstants\MODULE_REVERSE.

Referenced by dropTable(), ilDBPdoMySQL\migrateAllTablesToCollation(), and tableColumnExists().

1059  {
1060  switch ($module) {
1062  return $this->manager;
1064  return $this->reverse;
1065  }
1066  throw new LogicException('module "' . $module . '" not available');
1067  }
ilDBPdoManager $manager
ilDBPdoReverse $reverse
+ Here is the caller graph for this function:

◆ locate()

ilDBPdo::locate ( string  $needle,
string  $string,
int  $start_pos = 1 
)

Implements ilDBInterface.

Definition at line 1105 of file class.ilDBPdo.php.

1105  : string
1106  {
1107  return $this->manager->getQueryUtils()->locate($needle, $string, $start_pos);
1108  }

◆ lockTables()

ilDBPdo::lockTables ( array  $tables)
Deprecated:
Use ilAtomQuery instead

Implements ilDBInterface.

Definition at line 754 of file class.ilDBPdo.php.

754  : void
755  {
756  assert(is_array($tables));
757  $lock = $this->manager->getQueryUtils()->lock($tables);
758  $this->pdo->exec($lock);
759  }

◆ lower()

ilDBPdo::lower ( string  $expression)
Parameters
string$a_exp

Implements ilDBInterface.

Definition at line 974 of file class.ilDBPdo.php.

974  : string
975  {
976  return " LOWER(" . $expression . ") ";
977  }

◆ manipulate()

ilDBPdo::manipulate ( string  $query)
Exceptions
ilDatabaseException

Implements ilDBInterface.

Definition at line 551 of file class.ilDBPdo.php.

References $DIC, Vendor\Package\$e, ILIAS\Repository\int(), and sanitizeMB4StringIfNotSupported().

Referenced by manipulateF().

551  : int
552  {
553  global $DIC;
554  $ilBench = $DIC['ilBench'] ?? null;
555  try {
556  $query = $this->sanitizeMB4StringIfNotSupported($query);
557  if ($ilBench instanceof ilBenchmark) {
558  $ilBench->startDbBench($query);
559  }
560  $num_affected_rows = $this->pdo->exec($query);
561  if ($ilBench instanceof ilBenchmark) {
562  $ilBench->stopDbBench();
563  }
564  } catch (PDOException $e) {
565  throw new ilDatabaseException($e->getMessage() . ' QUERY: ' . $query, (int) $e->getCode());
566  }
567 
568  return (int) $num_affected_rows;
569  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
sanitizeMB4StringIfNotSupported(string $query)
string to sanitize, all MB4-Characters like emojis will re replaced with ??? string sanitized query ...
Class ilBenchmark.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ manipulateF()

ilDBPdo::manipulateF ( string  $query,
array  $types,
array  $values 
)
Parameters
string[]$types
Exceptions
ilDatabaseException

Implements ilDBInterface.

Definition at line 797 of file class.ilDBPdo.php.

References manipulate(), and quote().

Referenced by replace(), and update().

797  : int
798  {
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)");
801  }
802  $quoted_values = array();
803  foreach ($types as $k => $t) {
804  $quoted_values[] = $this->quote($values[$k], $t);
805  }
806  $query = vsprintf($query, $quoted_values);
807 
808  return $this->manipulate($query);
809  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
manipulate(string $query)
quote($value, ?string $type=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ migrateAllTablesToCollation()

ilDBPdo::migrateAllTablesToCollation ( string  $collation = ilDBConstants::MYSQL_COLLATION_UTF8MB4)

Implements ilDBPdoInterface.

Definition at line 1316 of file class.ilDBPdo.php.

1316  : array
1317  {
1318  return array();
1319  }

◆ migrateAllTablesToEngine()

ilDBPdo::migrateAllTablesToEngine ( string  $engine = ilDBConstants::MYSQL_ENGINE_INNODB)
Returns
array of failed tables

Implements ilDBPdoInterface.

Definition at line 1308 of file class.ilDBPdo.php.

1308  : array
1309  {
1310  return array();
1311  }

◆ modifyTableColumn()

ilDBPdo::modifyTableColumn ( string  $table,
string  $column,
array  $attributes 
)
Exceptions

Implements ilDBInterface.

Definition at line 1113 of file class.ilDBPdo.php.

References Vendor\Package\$a, $field_definition, and checkColumnDefinition().

1113  : bool
1114  {
1115  $def = $this->reverse->getTableFieldDefinition($table, $column);
1116 
1117  $analyzer = new ilDBAnalyzer($this);
1118  $best_alt = $analyzer->getBestDefinitionAlternative($def);
1119  $def = $def[$best_alt];
1120  unset($def["nativetype"], $def["mdb2type"]);
1121 
1122  // check attributes
1123  $ilDBPdoFieldDefinition = $this->field_definition;
1124 
1125  $type = $attributes["type"] ?? $def["type"];
1126 
1127  foreach (array_keys($def) as $k) {
1128  if ($k !== "type" && !$ilDBPdoFieldDefinition->isAllowedAttribute($k, $type)) {
1129  unset($def[$k]);
1130  }
1131  }
1132  $check_array = $def;
1133  foreach ($attributes as $k => $v) {
1134  $check_array[$k] = $v;
1135  }
1136  if (!$this->checkColumnDefinition($check_array, true)) {
1137  throw new ilDatabaseException("ilDB Error: modifyTableColumn(" . $table . ", " . $column . ")");
1138  }
1139 
1140  foreach ($attributes as $a => $v) {
1141  $def[$a] = $v;
1142  }
1143 
1144  $attributes["definition"] = $def;
1145 
1146  $changes = array(
1147  "change" => array(
1148  $column => $attributes,
1149  ),
1150  );
1151 
1152  return $this->manager->alterTable($table, $changes, false);
1153  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkColumnDefinition(array $a_def, bool $a_modify_mode=false)
array $attributes
ilDBPdoFieldDefinition $field_definition
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
This class gives all kind of DB information using the database manager and reverse module...
+ Here is the call graph for this function:

◆ nextId()

ilDBPdo::nextId ( string  $table_name)
abstract
Parameters
$table_namestring

Implements ilDBInterface.

Referenced by quoteIdentifier().

+ Here is the caller graph for this function:

◆ now()

ilDBPdo::now ( )
Returns
string the now statement

Implements ilDBInterface.

Definition at line 839 of file class.ilDBPdo.php.

Referenced by quote().

839  : string
840  {
841  return $this->manager->getQueryUtils()->now();
842  }
+ Here is the caller graph for this function:

◆ numRows()

ilDBPdo::numRows ( ilDBStatement  $statement)

Implements ilDBInterface.

Definition at line 583 of file class.ilDBPdo.php.

References ilDBStatement\rowCount().

583  : int
584  {
585  return $statement->rowCount();
586  }
+ Here is the call graph for this function:

◆ prepare()

ilDBPdo::prepare ( string  $query,
?array  $types = null,
?array  $result_types = null 
)

Definition at line 993 of file class.ilDBPdo.php.

993  : ilDBStatement
994  {
995  return new ilPDOStatement($this->pdo->prepare($query));
996  }
Class ilPDOStatement is a Wrapper Class for PDOStatement.

◆ prepareManip()

ilDBPdo::prepareManip ( string  $query,
?array  $types = null 
)

Implements ilDBInterface.

Definition at line 988 of file class.ilDBPdo.php.

Referenced by update().

988  : ilDBStatement
989  {
990  return new ilPDOStatement($this->pdo->prepare($query));
991  }
Class ilPDOStatement is a Wrapper Class for PDOStatement.
+ Here is the caller graph for this function:

◆ primaryExistsByFields()

ilDBPdo::primaryExistsByFields ( string  $table_name,
array  $fields 
)

Implements ilDBInterface.

Definition at line 1535 of file class.ilDBPdo.php.

1535  : bool
1536  {
1537  $constraints = $this->manager->listTableConstraints($table_name);
1538 
1539  if (in_array('primary', $constraints)) {
1540  $definitions = $this->reverse->getTableConstraintDefinition($table_name, 'primary');
1541  $primary_fields = array_keys($definitions['fields']);
1542  sort($primary_fields);
1543  sort($fields);
1544 
1545  return $primary_fields === $fields;
1546  }
1547  return false;
1548  }

◆ query()

ilDBPdo::query ( string  $query)
Exceptions
ilDatabaseException

Implements ilDBInterface.

Definition at line 352 of file class.ilDBPdo.php.

References $DIC, Vendor\Package\$e, $res, appendLimit(), and ILIAS\Repository\int().

Referenced by addFulltextIndex(), createDatabase(), dropFulltextIndex(), getDBVersion(), isFulltextIndex(), ilDBPdoMySQL\nextId(), and queryF().

352  : ilDBStatement
353  {
354  global $DIC;
355  $ilBench = $DIC['ilBench'] ?? null;
356 
357  $query = $this->appendLimit($query);
358 
359  try {
360  if ($ilBench instanceof ilBenchmark) {
361  $ilBench->startDbBench($query);
362  }
363  $res = $this->pdo->query($query);
364  if ($ilBench instanceof ilBenchmark) {
365  $ilBench->stopDbBench();
366  }
367  } catch (PDOException $e) {
368  throw new ilDatabaseException($e->getMessage() . ' QUERY: ' . $query, (int) $e->getCode());
369  }
370 
371  $err = $this->pdo->errorCode();
372  if ($err !== PDO::ERR_NONE) {
373  $info = $this->pdo->errorInfo();
374  $info_message = $info[2];
375  throw new ilDatabaseException($info_message . ' QUERY: ' . $query);
376  }
377 
378  return new ilPDOStatement($res);
379  }
$res
Definition: ltiservices.php:69
Class ilPDOStatement is a Wrapper Class for PDOStatement.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
appendLimit(string $query)
global $DIC
Definition: feed.php:28
Class ilBenchmark.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryCol()

ilDBPdo::queryCol ( string  $query,
int  $type = PDO::FETCH_ASSOC,
int  $colnum = 0 
)

Implements ilDBPdoInterface.

Definition at line 1256 of file class.ilDBPdo.php.

References ilDBConstants\FETCHMODE_ASSOC, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilDBPdoMySQL\migrateAllTablesToEngine().

1256  : array
1257  {
1258  switch ($type) {
1260  $type = PDO::FETCH_ASSOC;
1261  break;
1263  $type = PDO::FETCH_OBJ;
1264  break;
1265  default:
1266  $type = PDO::FETCH_ASSOC;
1267  break;
1268  }
1269 
1270  return $this->pdo->query($query, PDO::FETCH_ASSOC)->fetchAll(PDO::FETCH_COLUMN, $colnum);
1271  }
+ Here is the caller graph for this function:

◆ queryF()

ilDBPdo::queryF ( string  $query,
array  $types,
array  $values 
)
Parameters
string[]$types
Exceptions

Implements ilDBInterface.

Definition at line 779 of file class.ilDBPdo.php.

References query(), and quote().

779  : ilDBStatement
780  {
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)");
783  }
784  $quoted_values = array();
785  foreach ($types as $k => $t) {
786  $quoted_values[] = $this->quote($values[$k], $t);
787  }
788  $query = vsprintf($query, $quoted_values);
789 
790  return $this->query($query);
791  }
query(string $query)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
quote($value, ?string $type=null)
+ Here is the call graph for this function:

◆ queryRow()

ilDBPdo::queryRow ( string  $query,
?array  $types = null,
int  $fetchmode = ilDBConstants::FETCHMODE_DEFAULT 
)

Implements ilDBPdoInterface.

Definition at line 1273 of file class.ilDBPdo.php.

References ilDBConstants\FETCHMODE_ASSOC, and ilDBConstants\FETCHMODE_OBJECT.

1277  : array {
1278  switch ($fetchmode) {
1280  $type = PDO::FETCH_ASSOC;
1281  break;
1283  $type = PDO::FETCH_OBJ;
1284  break;
1285  default:
1286  $type = PDO::FETCH_ASSOC;
1287  break;
1288  }
1289 
1290  return $this->pdo->query($query, $type)->fetch();
1291  }

◆ quote()

ilDBPdo::quote (   $value,
?string  $type = null 
)

Definition at line 588 of file class.ilDBPdo.php.

References ILIAS\Repository\int(), now(), ilDBConstants\T_DATE, ilDBConstants\T_DATETIME, ilDBConstants\T_FLOAT, ilDBConstants\T_INTEGER, ilDBConstants\T_TEXT, and ilDBConstants\T_TIMESTAMP.

Referenced by equals(), insert(), manipulateF(), queryF(), and update().

588  : string
589  {
590  if ($value === null) {
591  return 'NULL';
592  }
593 
594  $pdo_type = PDO::PARAM_STR;
595  switch ($type) {
599  if ($value === '') {
600  return 'NULL';
601  }
602  if ($value === $this->now()) {
603  return $value;
604  }
605  $value = (string) $value;
606  break;
608  return (string) (int) $value;
610  $pdo_type = PDO::PARAM_INT;
611  $value = (string) $value;
612  break;
614  default:
615  $value = (string) $value;
616  $pdo_type = PDO::PARAM_STR;
617  break;
618  }
619 
620  return $this->pdo->quote((string) $value, $pdo_type);
621  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quoteIdentifier()

ilDBPdo::quoteIdentifier ( string  $identifier,
bool  $check_option = false 
)

Implements ilDBInterface.

Definition at line 168 of file class.ilDBPdo.php.

References ILIAS\Repository\int(), and nextId().

Referenced by ilDBPdoManager\createConstraint(), insert(), ilDBPdoMySQL\nextId(), replace(), and update().

168  : string
169  {
170  return '`' . preg_replace('/[^a-zA-Z0-9_$]/', '', $identifier) . '`';
171  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renameTable()

ilDBPdo::renameTable ( string  $name,
string  $new_name 
)
Exceptions

Implements ilDBInterface.

Definition at line 1163 of file class.ilDBPdo.php.

References Vendor\Package\$e, checkTableName(), getSequenceName(), and sequenceExists().

1163  : bool
1164  {
1165  // check table name
1166  try {
1167  $this->checkTableName($new_name);
1168  } catch (ilDatabaseException $e) {
1169  throw new ilDatabaseException(
1170  "ilDB Error: renameTable(" . $name . "," . $new_name . ")<br />" . $e->getMessage(),
1171  $e->getCode()
1172  );
1173  }
1174 
1175  $this->manager->alterTable($name, ["name" => $new_name], false);
1176  if ($this->sequenceExists($name)) {
1177  $this->manager->alterTable(
1178  $this->getSequenceName($name),
1179  ["name" => $this->getSequenceName($new_name)],
1180  false
1181  );
1182  }
1183  // The abstraction_progress is no longer used in ILIAS, see http://www.ilias.de/mantis/view.php?id=19513
1184  // $query = "UPDATE abstraction_progress " . "SET table_name = " . $this->quote($a_new_name, 'text') . " " . "WHERE table_name = "
1185  // . $this->quote($a_name, 'text');
1186  // $this->pdo->query($query);
1187 
1188  return true;
1189  }
checkTableName(string $a_name)
getSequenceName(string $table_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
sequenceExists(string $sequence)
+ Here is the call graph for this function:

◆ renameTableColumn()

ilDBPdo::renameTableColumn ( string  $table_name,
string  $column_old_name,
string  $column_new_name 
)
Exceptions

Implements ilDBInterface.

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

References Vendor\Package\$f, and checkColumnName().

414  : bool
415  {
416  // check table name
417  if (!$this->checkColumnName($column_new_name)) {
418  throw new ilDatabaseException("ilDB Error: renameTableColumn(" . $table_name . "," . $column_old_name . "," . $column_new_name . ")");
419  }
420 
421  $def = $this->reverse->getTableFieldDefinition($table_name, $column_old_name);
422 
423  $analyzer = new ilDBAnalyzer($this);
424  $best_alt = $analyzer->getBestDefinitionAlternative($def);
425  $def = $def[$best_alt];
426  unset($def["nativetype"]);
427  unset($def["mdb2type"]);
428 
429  $f["definition"] = $def;
430  $f["name"] = $column_new_name;
431 
432  $changes = array(
433  "rename" => array(
434  $column_old_name => $f,
435  ),
436  );
437 
438  return $this->manager->alterTable($table_name, $changes, false);
439  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkColumnName(string $a_name)
This class gives all kind of DB information using the database manager and reverse module...
+ Here is the call graph for this function:

◆ replace()

ilDBPdo::replace ( string  $table,
array  $primary_keys,
array  $other_columns 
)

Replace into method.

Parameters
stringtable name
arrayprimary key values: array("field1" => array("text", $name), "field2" => ...)
arrayother values: array("field1" => array("text", $name), "field2" => ...)
Returns
int The number of rows affected by the manipulation

Implements ilDBInterface.

Definition at line 844 of file class.ilDBPdo.php.

References $q, ILIAS\Repository\int(), manipulateF(), and quoteIdentifier().

844  : int
845  {
846  $a_columns = array_merge($primary_keys, $other_columns);
847  $fields = [];
848  $placeholders = [];
849  $types = [];
850  $values = [];
851 
852  foreach ($a_columns as $k => $col) {
853  $fields[] = $this->quoteIdentifier($k);
854  $placeholders[] = "%s";
855  $placeholders2[] = ":$k";
856  $types[] = $col[0];
857 
858  // integer auto-typecast (this casts bool values to integer)
859  if ($col[0] === 'integer' && !is_null($col[1])) {
860  $col[1] = (int) $col[1];
861  }
862 
863  $values[] = $col[1];
864  }
865 
866  $q = "REPLACE INTO " . $table . " (" . implode(",", $fields) . ") VALUES (" . implode(",", $placeholders) . ")";
867 
868  return $this->manipulateF($q, $types, $values);
869  }
manipulateF(string $query, array $types, array $values)
quoteIdentifier(string $identifier, bool $check_option=false)
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ rollback()

ilDBPdo::rollback ( )
Exceptions

Implements ilDBInterface.

Definition at line 1232 of file class.ilDBPdo.php.

References supports().

1232  : bool
1233  {
1234  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1235  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1236  }
1237 
1238  return $this->pdo->rollBack();
1239  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
supports(string $feature)
+ Here is the call graph for this function:

◆ sanitizeMB4StringIfNotSupported()

ilDBPdo::sanitizeMB4StringIfNotSupported ( string  $query)

Parameters
$querystring to sanitize, all MB4-Characters like emojis will re replaced with ???
Returns
string sanitized query

Implements ilDBInterface.

Definition at line 1468 of file class.ilDBPdo.php.

References doesCollationSupportMB4Strings(), and ilDBConstants\MB4_REPLACEMENT.

Referenced by insert(), manipulate(), and update().

1468  : string
1469  {
1470  if (!$this->doesCollationSupportMB4Strings()) {
1471  $query_replaced = preg_replace(
1472  '/[\x{10000}-\x{10FFFF}]/u',
1474  $query
1475  );
1476  if (!empty($query_replaced)) {
1477  return $query_replaced;
1478  }
1479  }
1480 
1481  return $query;
1482  }
doesCollationSupportMB4Strings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sequenceExists()

ilDBPdo::sequenceExists ( string  $sequence)

Implements ilDBInterface.

Definition at line 1077 of file class.ilDBPdo.php.

References listSequences().

Referenced by ilDBPdoMySQL\migrateAllTablesToEngine(), ilDBPdoMySQL\migrateTableToEngine(), and renameTable().

1077  : bool
1078  {
1079  return in_array($sequence, $this->listSequences(), true);
1080  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCharset()

ilDBPdo::setCharset ( string  $charset)

Definition at line 908 of file class.ilDBPdo.php.

References $charset.

908  : void
909  {
910  $this->charset = $charset;
911  }
string $charset

◆ setDBHost()

ilDBPdo::setDBHost ( string  $host)

Implements ilDBInterface.

Definition at line 958 of file class.ilDBPdo.php.

References setHost().

958  : void
959  {
960  $this->setHost($host);
961  }
setHost(string $host)
string $host
+ Here is the call graph for this function:

◆ setDbname()

ilDBPdo::setDbname ( string  $dbname)

Definition at line 898 of file class.ilDBPdo.php.

References $dbname.

Referenced by createDatabase(), and initFromIniFile().

898  : void
899  {
900  $this->dbname = $dbname;
901  }
string $dbname
+ Here is the caller graph for this function:

◆ setDBPassword()

ilDBPdo::setDBPassword ( string  $password)

Implements ilDBInterface.

Definition at line 953 of file class.ilDBPdo.php.

References setPassword().

953  : void
954  {
955  $this->setPassword($password);
956  }
setPassword(string $password)
string $password
+ Here is the call graph for this function:

◆ setDBPort()

ilDBPdo::setDBPort ( int  $port)

Implements ilDBInterface.

Definition at line 948 of file class.ilDBPdo.php.

References setPort().

948  : void
949  {
950  $this->setPort($port);
951  }
setPort(int $port)
+ Here is the call graph for this function:

◆ setDBType()

ilDBPdo::setDBType ( string  $type)

Definition at line 726 of file class.ilDBPdo.php.

References $DIC, $ilDB, and ilDBInterface\getReservedWords().

Referenced by initFromIniFile().

726  : void
727  {
728  $this->db_type = $type;
729  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDBUser()

ilDBPdo::setDBUser ( string  $user)

Implements ilDBInterface.

Definition at line 943 of file class.ilDBPdo.php.

References setUsername().

943  : void
944  {
945  $this->setUsername($user);
946  }
setUsername(string $username)
+ Here is the call graph for this function:

◆ setFieldDefinition()

ilDBPdo::setFieldDefinition ( \ilDBPdoFieldDefinition  $field_definition)

Definition at line 107 of file class.ilDBPdo.php.

References $field_definition.

107  : void
108  {
109  $this->field_definition = $field_definition;
110  }
ilDBPdoFieldDefinition $field_definition

◆ setHost()

ilDBPdo::setHost ( string  $host)

Definition at line 888 of file class.ilDBPdo.php.

References $host.

Referenced by initFromIniFile(), and setDBHost().

888  : void
889  {
890  $this->host = $host;
891  }
string $host
+ Here is the caller graph for this function:

◆ setLimit()

ilDBPdo::setLimit ( int  $limit,
int  $offset = 0 
)

Set the Limit for the next Query.

Implements ilDBInterface.

Definition at line 822 of file class.ilDBPdo.php.

References $limit, and $offset.

822  : void
823  {
824  $this->limit = $limit;
825  $this->offset = $offset;
826  }

◆ setPassword()

ilDBPdo::setPassword ( string  $password)

Definition at line 928 of file class.ilDBPdo.php.

References $password.

Referenced by initFromIniFile(), and setDBPassword().

928  : void
929  {
930  $this->password = $password;
931  }
string $password
+ Here is the caller graph for this function:

◆ setPort()

ilDBPdo::setPort ( int  $port)

Definition at line 938 of file class.ilDBPdo.php.

References $port.

Referenced by initFromIniFile(), and setDBPort().

938  : void
939  {
940  $this->port = $port;
941  }
+ Here is the caller graph for this function:

◆ setStorageEngine()

ilDBPdo::setStorageEngine ( string  $storage_engine)

Implements ilDBInterface.

Definition at line 1246 of file class.ilDBPdo.php.

References $storage_engine.

1246  : void
1247  {
1248  $this->storage_engine = $storage_engine;
1249  }
string $storage_engine

◆ setUsername()

ilDBPdo::setUsername ( string  $username)

Definition at line 918 of file class.ilDBPdo.php.

References $username.

Referenced by initFromIniFile(), and setDBUser().

918  : void
919  {
920  $this->username = $username;
921  }
string $username
+ Here is the caller graph for this function:

◆ substr()

ilDBPdo::substr ( string  $a_exp,
int  $a_pos = 1,
int  $a_len = -1 
)

Definition at line 979 of file class.ilDBPdo.php.

979  : string
980  {
981  $lenstr = "";
982  if ($a_len > -1) {
983  $lenstr = ", " . $a_len;
984  }
985  return " SUBSTR(" . $a_exp . ", " . $a_pos . $lenstr . ") ";
986  }

◆ supports()

ilDBPdo::supports ( string  $feature)

Implements ilDBInterface.

Definition at line 1033 of file class.ilDBPdo.php.

References supportsFulltext(), supportsSlave(), and supportsTransactions().

Referenced by beginTransaction(), commit(), and rollback().

1033  : bool
1034  {
1035  switch ($feature) {
1036  case self::FEATURE_TRANSACTIONS:
1037  return $this->supportsTransactions();
1038  case self::FEATURE_FULLTEXT:
1039  return $this->supportsFulltext();
1040  case self::FEATURE_SLAVE:
1041  return $this->supportsSlave();
1042  default:
1043  return false;
1044  }
1045  }
supportsTransactions()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportsCollationMigration()

ilDBPdo::supportsCollationMigration ( )

Implements ilDBPdoInterface.

Definition at line 1324 of file class.ilDBPdo.php.

1324  : bool
1325  {
1326  return false;
1327  }

◆ supportsEngineMigration()

ilDBPdo::supportsEngineMigration ( )

Implements ilDBPdoInterface.

Definition at line 1329 of file class.ilDBPdo.php.

1329  : bool
1330  {
1331  return false;
1332  }

◆ supportsFulltext()

ilDBPdo::supportsFulltext ( )

Implements ilDBInterface.

Definition at line 1023 of file class.ilDBPdo.php.

Referenced by addIndex(), and supports().

1023  : bool
1024  {
1025  return false;
1026  }
+ Here is the caller graph for this function:

◆ supportsSlave()

ilDBPdo::supportsSlave ( )

Implements ilDBInterface.

Definition at line 1018 of file class.ilDBPdo.php.

Referenced by supports().

1018  : bool
1019  {
1020  return false;
1021  }
+ Here is the caller graph for this function:

◆ supportsTransactions()

ilDBPdo::supportsTransactions ( )

Implements ilDBInterface.

Definition at line 1028 of file class.ilDBPdo.php.

Referenced by supports().

1028  : bool
1029  {
1030  return false;
1031  }
+ Here is the caller graph for this function:

◆ tableColumnExists()

ilDBPdo::tableColumnExists ( string  $table_name,
string  $column_name 
)

Implements ilDBInterface.

Definition at line 295 of file class.ilDBPdo.php.

References loadModule(), and ilDBConstants\MODULE_MANAGER.

295  : bool
296  {
297  $fields = $this->loadModule(ilDBConstants::MODULE_MANAGER)->listTableFields($table_name);
298 
299  return in_array($column_name, $fields, true);
300  }
loadModule(string $module)
+ Here is the call graph for this function:

◆ tableExists()

ilDBPdo::tableExists ( string  $table_name)

Implements ilDBInterface.

Definition at line 285 of file class.ilDBPdo.php.

285  : bool
286  {
287  $result = $this->pdo->prepare("SHOW TABLES LIKE :table_name");
288  $result->execute(array('table_name' => $table_name));
289  $return = $result->rowCount();
290  $result->closeCursor();
291 
292  return $return > 0;
293  }

◆ uniqueConstraintExists()

ilDBPdo::uniqueConstraintExists ( string  $table,
array  $fields 
)

Implements ilDBPdoInterface.

Definition at line 1407 of file class.ilDBPdo.php.

References Vendor\Package\$c, and Vendor\Package\$f.

1407  : bool
1408  {
1409  $analyzer = new ilDBAnalyzer();
1410  $cons = $analyzer->getConstraintsInformation($table);
1411  foreach ($cons as $c) {
1412  if ($c["type"] === "unique" && count($fields) === count($c["fields"])) {
1413  $all_in = true;
1414  foreach ($fields as $f) {
1415  if (!isset($c["fields"][$f])) {
1416  $all_in = false;
1417  }
1418  }
1419  if ($all_in) {
1420  return true;
1421  }
1422  }
1423  }
1424 
1425  return false;
1426  }
This class gives all kind of DB information using the database manager and reverse module...

◆ unixTimestamp()

ilDBPdo::unixTimestamp ( )

Implements ilDBPdoInterface.

Definition at line 1446 of file class.ilDBPdo.php.

1446  : string
1447  {
1448  return "UNIX_TIMESTAMP()";
1449  }

◆ unlockTables()

ilDBPdo::unlockTables ( )
Exceptions

Implements ilDBInterface.

Definition at line 765 of file class.ilDBPdo.php.

765  : void
766  {
767  $this->pdo->exec($this->manager->getQueryUtils()->unlock());
768  }

◆ update()

ilDBPdo::update ( string  $table_name,
array  $values,
array  $where 
)

$where MUST contain existing columns only.

statements like [1 => ['integer', 1]] will not work, use a full query and

See also
manipulate() instead in that case.
Returns
int The number of rows affected by the manipulation

Implements ilDBInterface.

Definition at line 470 of file class.ilDBPdo.php.

References $q, $r, ilDBInterface\execute(), free(), ILIAS\Repository\int(), manipulateF(), prepareManip(), quote(), quoteIdentifier(), and sanitizeMB4StringIfNotSupported().

470  : int
471  {
472  $fields = array();
473  $field_values = array();
474  $placeholders = array();
475  $placeholders_full = array();
476  $types = array();
477  $values = array();
478  $lobs = false;
479  $lob = array();
480  foreach ($columns as $k => $col) {
481  $field_value = $col[1];
482  $fields[] = $k;
483  $placeholders[] = "%s";
484  $placeholders_full[] = ":$k";
485  $types[] = $col[0];
486 
487  if (($col[0] === "blob" || $col[0] === "clob" || $col[0] === 'text') && is_string($field_value)) {
488  $field_value = $this->sanitizeMB4StringIfNotSupported($field_value);
489  }
490 
491  // integer auto-typecast (this casts bool values to integer)
492  if ($col[0] === 'integer' && !is_null($field_value)) {
493  $field_value = (int) $field_value;
494  }
495 
496  $values[] = $field_value;
497  $field_values[$k] = $field_value;
498  if ($col[0] === "blob" || $col[0] === "clob") {
499  $lobs = true;
500  }
501  }
502 
503  if ($lobs) {
504  $q = "UPDATE " . $this->quoteIdentifier($table_name) . " SET ";
505  $lim = "";
506  foreach ($fields as $k => $field) {
507  $q .= $lim . $this->quoteIdentifier($field) . " = " . $placeholders_full[$k];
508  $lim = ", ";
509  }
510  $q .= " WHERE ";
511  $lim = "";
512  foreach ($where as $k => $col) {
513  $q .= $lim . $this->quoteIdentifier($k) . " = " . $this->quote($col[1], $col[0]);
514  $lim = " AND ";
515  }
516 
517  $r = $this->prepareManip($q, $types);
518  $this->execute($r, $field_values);
519 
520  $num_affected_rows = $r->rowCount();
521 
522  $this->free($r);
523  } else {
524  foreach ($where as $k => $col) {
525  $types[] = $col[0];
526  $values[] = $col[1];
527  $field_values[$k] = $col;
528  }
529  $q = "UPDATE " . $this->quoteIdentifier($table_name) . " SET ";
530  $lim = "";
531  foreach ($fields as $k => $field) {
532  $q .= $lim . $this->quoteIdentifier($field) . " = " . $placeholders[$k];
533  $lim = ", ";
534  }
535  $q .= " WHERE ";
536  $lim = "";
537  foreach (array_keys($where) as $k) {
538  $q .= $lim . $this->quoteIdentifier($k) . " = %s";
539  $lim = " AND ";
540  }
541 
542  $num_affected_rows = $this->manipulateF($q, $types, $values);
543  }
544 
545  return $num_affected_rows;
546  }
manipulateF(string $query, array $types, array $values)
free(ilDBStatement $a_st)
execute(ilDBStatement $stmt, array $data=[])
quote($value, ?string $type=null)
quoteIdentifier(string $identifier, bool $check_option=false)
$q
Definition: shib_logout.php:21
sanitizeMB4StringIfNotSupported(string $query)
string to sanitize, all MB4-Characters like emojis will re replaced with ??? string sanitized query ...
prepareManip(string $query, ?array $types=null)
$r
+ Here is the call graph for this function:

◆ upper()

ilDBPdo::upper ( string  $expression)
Parameters
string$a_exp

Implements ilDBInterface.

Definition at line 966 of file class.ilDBPdo.php.

966  : string
967  {
968  return " UPPER(" . $expression . ") ";
969  }

◆ useSlave()

ilDBPdo::useSlave ( bool  $bool)

TODO.

Implements ilDBInterface.

Definition at line 814 of file class.ilDBPdo.php.

814  : bool
815  {
816  return false;
817  }

Field Documentation

◆ $attributes

array ilDBPdo::$attributes
protected
Initial value:
= array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
)

Definition at line 51 of file class.ilDBPdo.php.

Referenced by getAttributes().

◆ $charset

string ilDBPdo::$charset = 'utf8'
protected

Definition at line 37 of file class.ilDBPdo.php.

Referenced by generateDSN(), getCharset(), and setCharset().

◆ $db_type

string ilDBPdo::$db_type = ''
protected

Definition at line 55 of file class.ilDBPdo.php.

Referenced by getDBType().

◆ $dbname

string ilDBPdo::$dbname = ''
protected

Definition at line 36 of file class.ilDBPdo.php.

Referenced by getDbname(), and setDbname().

◆ $dsn

string ilDBPdo::$dsn = ''
protected

Definition at line 47 of file class.ilDBPdo.php.

Referenced by getDSN().

◆ $error_code

int ilDBPdo::$error_code = 0
protected

Definition at line 56 of file class.ilDBPdo.php.

Referenced by getLastErrorCode().

◆ $field_definition

ilDBPdoFieldDefinition ilDBPdo::$field_definition = null
protected

Definition at line 57 of file class.ilDBPdo.php.

Referenced by getFieldDefinition(), modifyTableColumn(), and setFieldDefinition().

◆ $host

string ilDBPdo::$host = ''
protected

Definition at line 35 of file class.ilDBPdo.php.

Referenced by getHost(), and setHost().

◆ $limit

int ilDBPdo::$limit = null
protected

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

Referenced by appendLimit(), and setLimit().

◆ $manager

ilDBPdoManager ilDBPdo::$manager
protected

◆ $offset

int ilDBPdo::$offset = null
protected

Definition at line 45 of file class.ilDBPdo.php.

Referenced by setLimit().

◆ $options

array ilDBPdo::$options = []

Definition at line 31 of file class.ilDBPdo.php.

Referenced by getAttributes().

◆ $password

string ilDBPdo::$password = ''
protected

Definition at line 39 of file class.ilDBPdo.php.

Referenced by getPassword(), and setPassword().

◆ $pdo

PDO ilDBPdo::$pdo = null
protected

Definition at line 41 of file class.ilDBPdo.php.

◆ $port

int ilDBPdo::$port = 3306
protected

Definition at line 40 of file class.ilDBPdo.php.

Referenced by getPort(), and setPort().

◆ $reverse

ilDBPdoReverse ilDBPdo::$reverse
protected

Definition at line 43 of file class.ilDBPdo.php.

Referenced by loadModule().

◆ $storage_engine

string ilDBPdo::$storage_engine = 'InnoDB'
protected

Definition at line 46 of file class.ilDBPdo.php.

Referenced by getStorageEngine(), and setStorageEngine().

◆ $username

string ilDBPdo::$username = ''
protected

Definition at line 38 of file class.ilDBPdo.php.

Referenced by getUsername(), and setUsername().

◆ FEATURE_FULLTEXT

const ilDBPdo::FEATURE_FULLTEXT = 'fulltext'

Definition at line 33 of file class.ilDBPdo.php.

◆ FEATURE_SLAVE

const ilDBPdo::FEATURE_SLAVE = 'slave'

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

◆ FEATURE_TRANSACTIONS

const ilDBPdo::FEATURE_TRANSACTIONS = 'transactions'

Definition at line 32 of file class.ilDBPdo.php.


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