ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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)
 Prepare a query (SELECT) statement to be used with execute. More...
 
 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)
 
 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
 
array 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 1487 of file class.ilDBPdo.php.

1495  : bool {
1496  return $this->manager->addForeignKey($foreign_key_name, $field_names, $table_name, $reference_field_names, $reference_table, $on_update, $on_delete);
1497  }

◆ 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:23
+ 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 = [];
643  foreach ($fields as $f) {
644  $definition_fields[$f] = [];
645  }
646  $definition = [
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 = [];
241  foreach ($primary_keys as $f) {
242  $fields[$f] = [];
243  }
244  $definition = [
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 $attributes, 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 = [
315  "add" => [
316  $column_name => $attributes,
317  ],
318  ];
319 
320  return $this->manager->alterTable($table_name, $changes, false);
321  }
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 1328 of file class.ilDBPdo.php.

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

1328  : bool
1329  {
1330  assert(is_array($fields));
1332 
1333  // check index name
1334  if (!$this->checkIndexName($name)) {
1335  throw new ilDatabaseException("ilDB Error: addUniqueConstraint(" . $table . "," . $name . ")");
1336  }
1337 
1338  $fields_corrected = [];
1339  foreach ($fields as $f) {
1340  $fields_corrected[$f] = [];
1341  }
1342  $definition = [
1343  'unique' => true,
1344  'fields' => $fields_corrected,
1345  ];
1346 
1347  return $manager->createConstraint($table, $this->constraintName($table, $name), $definition);
1348  }
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 1086 of file class.ilDBPdo.php.

References $limit, and null.

Referenced by query().

1086  : string
1087  {
1088  if ($this->limit !== null && $this->offset !== null) {
1089  $query .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
1090  $this->limit = null;
1091  $this->offset = null;
1092 
1093  return $query;
1094  }
1095 
1096  return $query;
1097  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ beginTransaction()

ilDBPdo::beginTransaction ( )
Exceptions

Implements ilDBInterface.

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

References supports().

1199  : bool
1200  {
1201  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1202  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1203  }
1204 
1205  return $this->pdo->beginTransaction();
1206  }
supports(string $feature)
+ Here is the call graph for this function:

◆ buildAtomQuery()

ilDBPdo::buildAtomQuery ( )

Implements ilDBInterface.

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

1381  : ilAtomQuery
1382  {
1383  return new ilAtomQueryLock($this);
1384  }
Class ilAtomQueryLock.
Interface ilAtomQuery Use ilAtomQuery to fire Database-Actions which have to be done without beeing i...

◆ buildIntegrityAnalyser()

ilDBPdo::buildIntegrityAnalyser ( )

Implements ilDBInterface.

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

1509  : Integrity
1510  {
1511  return new Integrity($this);
1512  }

◆ cast()

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

Implements ilDBInterface.

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

1482  : string
1483  {
1484  return $this->manager->getQueryUtils()->cast($a_field_name, $a_dest_type);
1485  }

◆ 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 1316 of file class.ilDBPdo.php.

References getFieldDefinition(), and null.

Referenced by addUniqueConstraint().

1316  : bool
1317  {
1318  $fd = $this->getFieldDefinition();
1319  if ($fd !== null) {
1320  return $fd->checkIndexName($name);
1321  }
1322  return false;
1323  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 1185 of file class.ilDBPdo.php.

Referenced by createTable(), and renameTable().

1185  : bool
1186  {
1187  return $this->field_definition->checkTableName($a_name);
1188  }
+ Here is the caller graph for this function:

◆ commit()

ilDBPdo::commit ( )
Exceptions

Implements ilDBInterface.

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

References supports().

1211  : bool
1212  {
1213  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1214  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1215  }
1216 
1217  return $this->pdo->commit();
1218  }
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 1081 of file class.ilDBPdo.php.

1081  : string
1082  {
1083  return $this->manager->getQueryUtils()->concat($values, $allow_null);
1084  }

◆ 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 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) {
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, []);
202  }
checkTableColumns(array $a_cols)
checkTableName(string $a_name)
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 1466 of file class.ilDBPdo.php.

Referenced by sanitizeMB4StringIfNotSupported().

1466  : bool
1467  {
1468  return false;
1469  }
+ Here is the caller graph for this function:

◆ dropForeignKey()

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

Implements ilDBInterface.

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

1499  : bool
1500  {
1501  return $this->manager->dropForeignKey($foreign_key_name, $table_name);
1502  }

◆ 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 1232 of file class.ilDBPdo.php.

Referenced by dropIndexByFields().

1232  : bool
1233  {
1234  return $this->manager->dropIndex($a_table, $a_name);
1235  }
+ 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 1407 of file class.ilDBPdo.php.

1407  : bool
1408  {
1409  return $this->manager->dropConstraint($table_name, "PRIMARY", true);
1410  }

◆ 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  }
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 = [
403  "remove" => [
404  $column_name => [],
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 1350 of file class.ilDBPdo.php.

References constraintName().

Referenced by dropUniqueConstraintByFields().

1350  : bool
1351  {
1352  return $this->manager->dropConstraint($table, $this->constraintName($table, $name), false);
1353  }
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 1355 of file class.ilDBPdo.php.

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

1355  : bool
1356  {
1357  $analyzer = new ilDBAnalyzer();
1358  $cons = $analyzer->getConstraintsInformation($table);
1359  foreach ($cons as $c) {
1360  if ($c["type"] === "unique" && count($fields) === count($c["fields"])) {
1361  $all_in = true;
1362  foreach ($fields as $f) {
1363  if (!isset($c["fields"][$f])) {
1364  $all_in = false;
1365  }
1366  }
1367  if ($all_in) {
1368  return $this->dropUniqueConstraint($table, $c['name']);
1369  }
1370  }
1371  }
1372 
1373  return false;
1374  }
dropUniqueConstraint(string $table, string $name="con")
$c
Definition: deliver.php:25
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 1277 of file class.ilDBPdo.php.

1277  : string
1278  {
1279  return $value;
1280  }

◆ escapePattern()

ilDBPdo::escapePattern ( string  $text)

Implements ilDBPdoInterface.

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

1282  : string
1283  {
1284  return $text;
1285  }

◆ executeMultiple()

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

Implements ilDBPdoInterface.

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

References ilDBInterface\execute().

1412  : array
1413  {
1414  foreach ($data as $set) {
1415  $this->execute($stmt, $set);
1416  }
1417  return [];
1418  }
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, ilDBStatement\fetch(), and null.

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:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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, ilDBStatement\fetchObject(), and null.

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:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 1504 of file class.ilDBPdo.php.

1504  : bool
1505  {
1506  return $this->manager->foreignKeyExists($foreign_key_name, $table_name);
1507  }

◆ free()

ilDBPdo::free ( ilDBStatement  $a_st)

Implements ilDBInterface.

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

Referenced by update().

1149  : void
1150  {
1151  $a_st->closeCursor();
1152  }
+ Here is the caller graph for this function:

◆ fromUnixtime()

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

Implements ilDBPdoInterface.

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

1420  : string
1421  {
1422  return "FROM_UNIXTIME(" . $expr . ")";
1423  }

◆ 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().

159  : void
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 [];
100  }
+ Here is the caller graph for this function:

◆ getAllowedAttributes()

ilDBPdo::getAllowedAttributes ( )

Returns
string[]

Implements ilDBInterface.

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

1066  : array
1067  {
1068  return $this->field_definition->getAllowedAttributes();
1069  }

◆ 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  }
array string $db_type

◆ getDBVersion()

ilDBPdo::getDBVersion ( )
Exceptions
ilDatabaseException

Implements ilDBPdoInterface.

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

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

1434  : string
1435  {
1436  $d = $this->fetchObject($this->query("SELECT VERSION() AS version"));
1437 
1438  if ($d !== null && $d->version) {
1439  return $d->version;
1440  }
1441  return 'Unknown';
1442  }
fetchObject(ilDBStatement $query_result)
query(string $query)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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  }
Class ilDBPdoFieldDefinition.
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 1376 of file class.ilDBPdo.php.

1376  : int
1377  {
1378  return (int) $this->pdo->lastInsertId();
1379  }

◆ 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 1272 of file class.ilDBPdo.php.

1272  : int
1273  {
1274  return $this->pdo->query('SELECT VERSION()')->fetchColumn();
1275  }

◆ getStorageEngine()

ilDBPdo::getStorageEngine ( )

Implements ilDBInterface.

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

References $storage_engine.

1242  : string
1243  {
1244  return $this->storage_engine;
1245  }
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 1474 of file class.ilDBPdo.php.

1474  : string
1475  {
1476  return $this->manager->getQueryUtils()->groupConcat($a_field_name, $a_seperator, $a_order);
1477  }

◆ 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)
setDbname(string $dbname)
global $DIC
Definition: shib_login.php:26
setPort(int $port)
setDBType(string $type)
$ini
Definition: raiseError.php:20
+ 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 quote(), quoteIdentifier(), and sanitizeMB4StringIfNotSupported().

441  : int
442  {
443  $real = [];
444  $fields = [];
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)
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 1190 of file class.ilDBPdo.php.

References $DIC.

1190  : bool
1191  {
1192  global $DIC;
1193  return (new ilDBPdoMySQLFieldDefinition($DIC->database()))->isReserved($a_word);
1194  }
global $DIC
Definition: shib_login.php:26
Class ilDBPdoMySQLFieldDefinition.

◆ 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 1076 of file class.ilDBPdo.php.

Referenced by sequenceExists().

1076  : array
1077  {
1078  return $this->manager->listSequences();
1079  }
+ Here is the caller graph for this function:

◆ listTables()

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

Implements ilDBInterface.

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

Referenced by ilDBPdoMySQL\migrateAllTablesToEngine().

1046  : array
1047  {
1048  return $this->manager->listTables();
1049  }
+ Here is the caller graph for this function:

◆ loadModule()

ilDBPdo::loadModule ( string  $module)
Returns
|

Implements ilDBInterface.

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

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

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

1055  {
1056  return match ($module) {
1059  default => throw new LogicException('module "' . $module . '" not available'),
1060  };
1061  }
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 1099 of file class.ilDBPdo.php.

1099  : string
1100  {
1101  return $this->manager->getQueryUtils()->locate($needle, $string, $start_pos);
1102  }

◆ 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(), null, 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(), $e);
566  }
567 
568  return (int) $num_affected_rows;
569  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
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 = [];
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  }
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 1295 of file class.ilDBPdo.php.

1295  : array
1296  {
1297  return [];
1298  }

◆ migrateAllTablesToEngine()

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

Implements ilDBPdoInterface.

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

1287  : array
1288  {
1289  return [];
1290  }

◆ modifyTableColumn()

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

Implements ilDBInterface.

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

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

1107  : bool
1108  {
1109  $def = $this->reverse->getTableFieldDefinition($table, $column);
1110 
1111  $analyzer = new ilDBAnalyzer($this);
1112  $best_alt = $analyzer->getBestDefinitionAlternative($def);
1113  $def = $def[$best_alt];
1114  unset($def["nativetype"], $def["mdb2type"]);
1115 
1116  // check attributes
1117  $ilDBPdoFieldDefinition = $this->field_definition;
1118 
1119  $type = $attributes["type"] ?? $def["type"];
1120 
1121  foreach (array_keys($def) as $k) {
1122  if ($k !== "type" && !$ilDBPdoFieldDefinition->isAllowedAttribute($k, $type)) {
1123  unset($def[$k]);
1124  }
1125  }
1126  $check_array = $def;
1127  foreach ($attributes as $k => $v) {
1128  $check_array[$k] = $v;
1129  }
1130  if (!$this->checkColumnDefinition($check_array, true)) {
1131  throw new ilDatabaseException("ilDB Error: modifyTableColumn(" . $table . ", " . $column . ")");
1132  }
1133 
1134  foreach ($attributes as $a => $v) {
1135  $def[$a] = $v;
1136  }
1137 
1138  $attributes["definition"] = $def;
1139 
1140  $changes = [
1141  "change" => [
1142  $column => $attributes,
1143  ],
1144  ];
1145 
1146  return $this->manager->alterTable($table, $changes, false);
1147  }
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  $a_query,
?array  $a_types = null,
?array  $a_result_types = null 
)

Prepare a query (SELECT) statement to be used with execute.

Implements ilDBInterface.

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 1514 of file class.ilDBPdo.php.

References ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

1514  : bool
1515  {
1516  $constraints = $this->manager->listTableConstraints($table_name);
1517 
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);
1522  sort($fields);
1523 
1524  return $primary_fields === $fields;
1525  }
1526  return false;
1527  }
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41
+ Here is the call graph for this function:

◆ query()

ilDBPdo::query ( string  $query)
Exceptions
ilDatabaseException

Implements ilDBInterface.

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

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

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(), $e);
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:66
Class ilPDOStatement is a Wrapper Class for PDOStatement.
appendLimit(string $query)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
Class ilBenchmark.
$info
Definition: entry_point.php:21
+ 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 1247 of file class.ilDBPdo.php.

References ilDBConstants\FETCHMODE_ASSOC, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilDBPdoMySQL\migrateAllTablesToEngine().

1247  : array
1248  {
1249  $type = match ($type) {
1250  ilDBConstants::FETCHMODE_ASSOC => PDO::FETCH_ASSOC,
1251  ilDBConstants::FETCHMODE_OBJECT => PDO::FETCH_OBJ,
1252  default => PDO::FETCH_ASSOC,
1253  };
1254 
1255  return $this->pdo->query($query, PDO::FETCH_ASSOC)->fetchAll(PDO::FETCH_COLUMN, $colnum);
1256  }
+ 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 = [];
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)
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 1258 of file class.ilDBPdo.php.

References ilDBConstants\FETCHMODE_ASSOC, and ilDBConstants\FETCHMODE_OBJECT.

1262  : array {
1263  $type = match ($fetchmode) {
1264  ilDBConstants::FETCHMODE_ASSOC => PDO::FETCH_ASSOC,
1265  ilDBConstants::FETCHMODE_OBJECT => PDO::FETCH_OBJ,
1266  default => PDO::FETCH_ASSOC,
1267  };
1268 
1269  return $this->pdo->query($query, $type)->fetch();
1270  }

◆ quote()

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

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

References ILIAS\Repository\int(), now(), null, 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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 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 1157 of file class.ilDBPdo.php.

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

1157  : bool
1158  {
1159  // check table name
1160  try {
1161  $this->checkTableName($new_name);
1162  } catch (ilDatabaseException $e) {
1163  throw new ilDatabaseException("ilDB Error: renameTable(" . $name . "," . $new_name . ")<br />" . $e->getMessage(), $e->getCode(), $e);
1164  }
1165 
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)],
1171  false
1172  );
1173  }
1174  // The abstraction_progress is no longer used in ILIAS, see http://www.ilias.de/mantis/view.php?id=19513
1175  // $query = "UPDATE abstraction_progress " . "SET table_name = " . $this->quote($a_new_name, 'text') . " " . "WHERE table_name = "
1176  // . $this->quote($a_name, 'text');
1177  // $this->pdo->query($query);
1178 
1179  return true;
1180  }
checkTableName(string $a_name)
getSequenceName(string $table_name)
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 = [
433  "rename" => [
434  $column_old_name => $f,
435  ],
436  ];
437 
438  return $this->manager->alterTable($table_name, $changes, false);
439  }
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:23
+ Here is the call graph for this function:

◆ rollback()

ilDBPdo::rollback ( )
Exceptions

Implements ilDBInterface.

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

References supports().

1223  : bool
1224  {
1225  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1226  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1227  }
1228 
1229  return $this->pdo->rollBack();
1230  }
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 1447 of file class.ilDBPdo.php.

References doesCollationSupportMB4Strings(), and ilDBConstants\MB4_REPLACEMENT.

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

1447  : string
1448  {
1449  if (!$this->doesCollationSupportMB4Strings()) {
1450  $query_replaced = preg_replace(
1451  '/[\x{10000}-\x{10FFFF}]/u',
1453  $query
1454  );
1455  if (!empty($query_replaced)) {
1456  return $query_replaced;
1457  }
1458  }
1459 
1460  return $query;
1461  }
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 1071 of file class.ilDBPdo.php.

References listSequences().

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

1071  : bool
1072  {
1073  return in_array($sequence, $this->listSequences(), true);
1074  }
+ 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, ilDBInterface\getReservedWords(), and null.

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 1237 of file class.ilDBPdo.php.

References $storage_engine.

1237  : void
1238  {
1239  $this->storage_engine = $storage_engine;
1240  }
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  return match ($feature) {
1036  self::FEATURE_TRANSACTIONS => $this->supportsTransactions(),
1037  self::FEATURE_FULLTEXT => $this->supportsFulltext(),
1038  self::FEATURE_SLAVE => $this->supportsSlave(),
1039  default => false,
1040  };
1041  }
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 1303 of file class.ilDBPdo.php.

1303  : bool
1304  {
1305  return false;
1306  }

◆ supportsEngineMigration()

ilDBPdo::supportsEngineMigration ( )

Implements ilDBPdoInterface.

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

1308  : bool
1309  {
1310  return false;
1311  }

◆ 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(['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 1386 of file class.ilDBPdo.php.

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

1386  : bool
1387  {
1388  $analyzer = new ilDBAnalyzer();
1389  $cons = $analyzer->getConstraintsInformation($table);
1390  foreach ($cons as $c) {
1391  if ($c["type"] === "unique" && count($fields) === count($c["fields"])) {
1392  $all_in = true;
1393  foreach ($fields as $f) {
1394  if (!isset($c["fields"][$f])) {
1395  $all_in = false;
1396  }
1397  }
1398  if ($all_in) {
1399  return true;
1400  }
1401  }
1402  }
1403 
1404  return false;
1405  }
$c
Definition: deliver.php:25
This class gives all kind of DB information using the database manager and reverse module...

◆ unixTimestamp()

ilDBPdo::unixTimestamp ( )

Implements ilDBPdoInterface.

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

1425  : string
1426  {
1427  return "UNIX_TIMESTAMP()";
1428  }

◆ 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 = [];
473  $field_values = [];
474  $placeholders = [];
475  $placeholders_full = [];
476  $types = [];
477  $values = [];
478  $lobs = false;
479  $lob = [];
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:23
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:
= [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION

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

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

◆ $charset

string ilDBPdo::$charset = 'utf8'
protected

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

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

◆ $db_type

array 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: