ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 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

◆ addFulltextIndex()

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

Implements ilDBInterface.

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

References constraintName(), and query().

Referenced by addIndex().

659  : bool
660  {
661  $i_name = $this->constraintName($table, $a_name) . "_idx";
662  $f_str = implode(",", $fields);
663  $q = "ALTER TABLE $table ADD FULLTEXT $i_name ($f_str)";
664  $this->query($q);
665  return true;
666  }
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:
+ 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 633 of file class.ilDBPdo.php.

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

633  : bool
634  {
635  assert(is_array($fields));
636  $this->field_definition->checkIndexName($index_name);
637 
638  $definition_fields = array();
639  foreach ($fields as $f) {
640  $definition_fields[$f] = array();
641  }
642  $definition = array(
643  'fields' => $definition_fields,
644  );
645 
646  if (!$fulltext) {
647  $this->manager->createIndex($table_name, $this->constraintName($table_name, $index_name), $definition);
648  } elseif ($this->supportsFulltext()) {
649  $this->addFulltextIndex($table_name, $fields, $index_name);
650  // TODO
651  }
652 
653  return true;
654  }
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 232 of file class.ilDBPdo.php.

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

232  : bool
233  {
234  assert(is_array($primary_keys));
235 
236  $fields = array();
237  foreach ($primary_keys as $f) {
238  $fields[$f] = array();
239  }
240  $definition = array(
241  'primary' => true,
242  'fields' => $fields,
243  );
244  $this->manager->createConstraint(
245  $table_name,
246  $this->constraintName($table_name, $this->getPrimaryKeyIdentifier()),
247  $definition
248  );
249 
250  return true;
251  }
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 301 of file class.ilDBPdo.php.

References checkColumnDefinition(), and checkColumnName().

301  : bool
302  {
303  if (!$this->checkColumnName($column_name)) {
304  throw new ilDatabaseException("ilDB Error: addTableColumn(" . $table_name . ", " . $column_name . ")");
305  }
306  if (!$this->checkColumnDefinition($attributes)) {
307  throw new ilDatabaseException("ilDB Error: addTableColumn(" . $table_name . ", " . $column_name . ")");
308  }
309 
310  $changes = array(
311  "add" => array(
312  $column_name => $attributes,
313  ),
314  );
315 
316  return $this->manager->alterTable($table_name, $changes, false);
317  }
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 1345 of file class.ilDBPdo.php.

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

1345  : bool
1346  {
1347  assert(is_array($fields));
1349 
1350  // check index name
1351  if (!$this->checkIndexName($name)) {
1352  throw new ilDatabaseException("ilDB Error: addUniqueConstraint(" . $table . "," . $name . ")");
1353  }
1354 
1355  $fields_corrected = array();
1356  foreach ($fields as $f) {
1357  $fields_corrected[$f] = array();
1358  }
1359  $definition = array(
1360  'unique' => true,
1361  'fields' => $fields_corrected,
1362  );
1363 
1364  return $manager->createConstraint($table, $this->constraintName($table, $name), $definition);
1365  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($format !==null) $name
Definition: metadata.php:247
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 1088 of file class.ilDBPdo.php.

References $limit, and $query.

Referenced by query().

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

◆ beginTransaction()

ilDBPdo::beginTransaction ( )
Exceptions

Implements ilDBInterface.

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

References supports().

1204  : bool
1205  {
1206  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1207  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1208  }
1209 
1210  return $this->pdo->beginTransaction();
1211  }
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 1398 of file class.ilDBPdo.php.

1398  : ilAtomQuery
1399  {
1400  return new ilAtomQueryLock($this);
1401  }
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...

◆ cast()

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

Implements ilDBInterface.

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

1499  : string
1500  {
1501  return $this->manager->getQueryUtils()->cast($a_field_name, $a_dest_type);
1502  }

◆ checkColumn()

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

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

References checkColumnDefinition(), and checkColumnName().

Referenced by checkTableColumns().

211  : bool
212  {
213  if (!$this->checkColumnName($a_col)) {
214  return false;
215  }
216  return $this->checkColumnDefinition($a_def);
217  }
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 219 of file class.ilDBPdo.php.

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

219  : bool
220  {
221  return $this->field_definition->checkColumnDefinition($a_def);
222  }
+ Here is the caller graph for this function:

◆ checkColumnName()

ilDBPdo::checkColumnName ( string  $a_name)

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

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

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

◆ checkIndexName()

ilDBPdo::checkIndexName ( string  $name)
Exceptions

Implements ilDBPdoInterface.

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

References getFieldDefinition().

Referenced by addUniqueConstraint().

1333  : bool
1334  {
1335  $fd = $this->getFieldDefinition();
1336  if ($fd !== null) {
1337  return $fd->checkIndexName($name);
1338  }
1339  return false;
1340  }
if($format !==null) $name
Definition: metadata.php:247
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 200 of file class.ilDBPdo.php.

References checkColumn().

Referenced by createTable().

200  : bool
201  {
202  foreach ($a_cols as $col => $def) {
203  if (!$this->checkColumn($col, $def)) {
204  return false;
205  }
206  }
207 
208  return true;
209  }
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 1190 of file class.ilDBPdo.php.

Referenced by createTable(), and renameTable().

1190  : bool
1191  {
1192  return $this->field_definition->checkTableName($a_name);
1193  }
+ Here is the caller graph for this function:

◆ commit()

ilDBPdo::commit ( )
Exceptions

Implements ilDBInterface.

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

References supports().

1216  : bool
1217  {
1218  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1219  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1220  }
1221 
1222  return $this->pdo->commit();
1223  }
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 1083 of file class.ilDBPdo.php.

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

◆ connect()

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

Implements ilDBInterface.

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

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

Referenced by createDatabase().

58  : ?bool
59  {
60  $this->generateDSN();
61  try {
62  $options = $this->getAttributes();
63  $this->pdo = new PDO($this->getDSN(), $this->getUsername(), $this->getPassword(), $options);
64  $this->initHelpers();
65  $this->initSQLMode();
66  } catch (Exception $e) {
67  $this->error_code = $e->getCode();
68  if ($return_false_for_error) {
69  return false;
70  }
71  throw $e;
72  }
73 
74  return ($this->pdo->errorCode() === PDO::ERR_NONE);
75  }
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 707 of file class.ilDBPdo.php.

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

707  : string
708  {
709  return $a_constraint;
710  }
+ 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 108 of file class.ilDBPdo.php.

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

108  : bool
109  {
110  $this->setDbname('');
111  $this->generateDSN();
112  $this->connect(true);
113  try {
114  $this->query($this->manager->getQueryUtils()->createDatabase($a_name, $a_charset, $a_collation));
115  return true;
116  } catch (PDOException $e) {
117  return false;
118  }
119  }
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 275 of file class.ilDBPdo.php.

275  : bool
276  {
277  $this->manager->createSequence($table_name, $start);
278  return true;
279  }

◆ createTable()

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

Implements ilDBInterface.

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

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

182  : bool {
183  // check table name
184  if (!$ignore_erros && !$this->checkTableName($table_name)) {
185  throw new ilDatabaseException("ilDB Error: createTable(" . $table_name . ")");
186  }
187 
188  // check definition array
189  if (!$ignore_erros && !$this->checkTableColumns($fields)) {
190  throw new ilDatabaseException("ilDB Error: createTable(" . $table_name . ")");
191  }
192 
193  if ($drop_table) {
194  $this->dropTable($table_name, false);
195  }
196 
197  return $this->manager->createTable($table_name, $fields, array());
198  }
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 1483 of file class.ilDBPdo.php.

Referenced by sanitizeMB4StringIfNotSupported().

1483  : bool
1484  {
1485  return false;
1486  }
+ Here is the caller graph for this function:

◆ dropFulltextIndex()

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

Drop fulltext index.

Implements ilDBInterface.

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

References constraintName(), and query().

671  : bool
672  {
673  $i_name = $this->constraintName($a_table, $a_name) . "_idx";
674  $this->query("ALTER TABLE $a_table DROP FULLTEXT $i_name");
675  return true;
676  }
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 1237 of file class.ilDBPdo.php.

Referenced by dropIndexByFields().

1237  : bool
1238  {
1239  return $this->manager->dropIndex($a_table, $a_name);
1240  }
+ Here is the caller graph for this function:

◆ dropIndexByFields()

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

Implements ilDBInterface.

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

References dropIndex().

256  : bool
257  {
258  foreach ($this->manager->listTableIndexes($table_name) as $idx_name) {
259  $def = $this->reverse->getTableIndexDefinition($table_name, $idx_name);
260  $idx_fields = array_keys($def['fields']);
261 
262  if ($idx_fields === $fields) {
263  return $this->dropIndex($table_name, $idx_name);
264  }
265  }
266 
267  return false;
268  }
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 1424 of file class.ilDBPdo.php.

1424  : bool
1425  {
1426  return $this->manager->dropConstraint($table_name, "PRIMARY", true);
1427  }

◆ dropSequence()

ilDBPdo::dropSequence ( string  $table_name)

Implements ilDBInterface.

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

387  : bool
388  {
389  $this->manager->dropSequence($table_name);
390  return true;
391  }

◆ dropTable()

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

Implements ilDBInterface.

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

References loadModule(), and ilDBConstants\MODULE_MANAGER.

Referenced by createTable().

322  : bool
323  {
324  $ilDBPdoManager = $this->loadModule(ilDBConstants::MODULE_MANAGER);
325  $tables = $ilDBPdoManager->listTables();
326  $table_exists = in_array($table_name, $tables);
327  if (!$table_exists && $error_if_not_existing) {
328  throw new ilDatabaseException("Table $table_name does not exist");
329  }
330 
331  // drop sequence
332  $sequences = $ilDBPdoManager->listSequences();
333  if (in_array($table_name, $sequences)) {
334  $ilDBPdoManager->dropSequence($table_name);
335  }
336 
337  // drop table
338  if ($table_exists) {
339  $ilDBPdoManager->dropTable($table_name);
340  }
341 
342  return true;
343  }
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 396 of file class.ilDBPdo.php.

396  : bool
397  {
398  $changes = array(
399  "remove" => array(
400  $column_name => array(),
401  ),
402  );
403 
404  return $this->manager->alterTable($table_name, $changes, false);
405  }

◆ dropUniqueConstraint()

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

Implements ilDBPdoInterface.

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

References $name, and constraintName().

Referenced by dropUniqueConstraintByFields().

1367  : bool
1368  {
1369  return $this->manager->dropConstraint($table, $this->constraintName($table, $name), false);
1370  }
if($format !==null) $name
Definition: metadata.php:247
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 1372 of file class.ilDBPdo.php.

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

1372  : bool
1373  {
1374  $analyzer = new ilDBAnalyzer();
1375  $cons = $analyzer->getConstraintsInformation($table);
1376  foreach ($cons as $c) {
1377  if ($c["type"] === "unique" && count($fields) === count($c["fields"])) {
1378  $all_in = true;
1379  foreach ($fields as $f) {
1380  if (!isset($c["fields"][$f])) {
1381  $all_in = false;
1382  }
1383  }
1384  if ($all_in) {
1385  return $this->dropUniqueConstraint($table, $c['name']);
1386  }
1387  }
1388  }
1389 
1390  return false;
1391  }
dropUniqueConstraint(string $table, string $name="con")
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ enableResultBuffering()

ilDBPdo::enableResultBuffering ( bool  $a_status)

Implements ilDBInterface.

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

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

994  : void
995  {
996  $this->pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $a_status);
997  }
+ 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 870 of file class.ilDBPdo.php.

References quote().

870  : string
871  {
872  if (!$emptyOrNull || $value != "") {
873  return $columns . " = " . $this->quote($value, $type);
874  }
875 
876  return "(" . $columns . " = '' OR $columns IS NULL)";
877  }
$type
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 1294 of file class.ilDBPdo.php.

1294  : string
1295  {
1296  return $value;
1297  }

◆ escapePattern()

ilDBPdo::escapePattern ( string  $text)

Implements ilDBPdoInterface.

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

1299  : string
1300  {
1301  return $text;
1302  }

◆ executeMultiple()

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

Implements ilDBPdoInterface.

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

References ilDBInterface\execute().

1429  : array
1430  {
1431  foreach ($data as $set) {
1432  $this->execute($stmt, $set);
1433  }
1434  return [];
1435  }
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 377 of file class.ilDBPdo.php.

References $data, and ilDBStatement\fetch().

377  : array
378  {
379  $return = [];
380  while ($data = $statement->fetch($fetch_mode)) {
381  $return[] = $data;
382  }
383 
384  return $return;
385  }
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 567 of file class.ilDBPdo.php.

References $res, and ilDBStatement\fetch().

Referenced by isFulltextIndex().

567  : ?array
568  {
569  $res = $statement->fetch(PDO::FETCH_ASSOC);
570  if ($res === null || $res === false) {
571  $statement->closeCursor();
572 
573  return null;
574  }
575 
576  return $res;
577  }
$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 454 of file class.ilDBPdo.php.

References $res, and ilDBStatement\fetchObject().

Referenced by getDBVersion().

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

◆ free()

ilDBPdo::free ( ilDBStatement  $a_st)

Implements ilDBInterface.

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

Referenced by update().

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

◆ fromUnixtime()

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

Implements ilDBPdoInterface.

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

1437  : string
1438  {
1439  return "FROM_UNIXTIME(" . $expr . ")";
1440  }

◆ generateDSN()

ilDBPdo::generateDSN ( )

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

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

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

156  {
157  $port = $this->getPort() !== 0 ? ";port=" . $this->getPort() : "";
158  $dbname = $this->getDbname() !== '' ? ';dbname=' . $this->getDbname() : '';
159  $host = $this->getHost();
160  $charset = ';charset=' . $this->getCharset();
161  $this->dsn = 'mysql:host=' . $host . $port . $dbname . $charset;
162  }
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 93 of file class.ilDBPdo.php.

Referenced by getAttributes().

93  : array
94  {
95  return array();
96  }
+ Here is the caller graph for this function:

◆ getAllowedAttributes()

ilDBPdo::getAllowedAttributes ( )

Returns
string[]

Implements ilDBInterface.

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

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

◆ getAttributes()

ilDBPdo::getAttributes ( )
protected

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

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

Referenced by connect().

83  : array
84  {
86  foreach ($this->getAdditionalAttributes() as $k => $v) {
87  $options[$k] = $v;
88  }
89 
90  return $options;
91  }
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 899 of file class.ilDBPdo.php.

References $charset.

Referenced by generateDSN().

899  : string
900  {
901  return $this->charset;
902  }
string $charset
+ Here is the caller graph for this function:

◆ getDbname()

ilDBPdo::getDbname ( )

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

References $dbname.

Referenced by generateDSN().

889  : string
890  {
891  return $this->dbname;
892  }
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 717 of file class.ilDBPdo.php.

References $db_type.

717  : string
718  {
719  return $this->db_type;
720  }
string $db_type

◆ getDBVersion()

ilDBPdo::getDBVersion ( )
Exceptions
ilDatabaseException

Implements ilDBPdoInterface.

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

References $d, fetchObject(), and query().

1451  : string
1452  {
1453  $d = $this->fetchObject($this->query("SELECT VERSION() AS version"));
1454 
1455  if ($d !== null && $d->version) {
1456  return $d->version;
1457  }
1458  return 'Unknown';
1459  }
fetchObject(ilDBStatement $query_result)
query(string $query)
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ 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 712 of file class.ilDBPdo.php.

References $dsn.

Referenced by connect().

712  : string
713  {
714  return $this->dsn;
715  }
string $dsn
+ Here is the caller graph for this function:

◆ getFieldDefinition()

ilDBPdo::getFieldDefinition ( )

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

References $field_definition.

Referenced by checkIndexName().

99  {
101  }
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 879 of file class.ilDBPdo.php.

References $host.

Referenced by generateDSN().

879  : string
880  {
881  return $this->host;
882  }
string $host
+ Here is the caller graph for this function:

◆ getIndexName()

ilDBPdo::getIndexName ( string  $index_name_base)

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

References ilDBPdoFieldDefinition\INDEX_FORMAT.

693  : string
694  {
695  return sprintf(ilDBPdoFieldDefinition::INDEX_FORMAT, preg_replace('/[^a-z0-9_\$]/i', '_', $index_name_base));
696  }

◆ getLastErrorCode()

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

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

References $error_code.

125  {
126  if ($this->pdo instanceof PDO) {
127  return $this->pdo->errorCode();
128  }
129 
130  return $this->error_code;
131  }
int $error_code

◆ getLastInsertId()

ilDBPdo::getLastInsertId ( )

Implements ilDBPdoInterface.

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

1393  : int
1394  {
1395  return (int) $this->pdo->lastInsertId();
1396  }

◆ getPassword()

ilDBPdo::getPassword ( )

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

References $password.

Referenced by connect().

919  : string
920  {
921  return $this->password;
922  }
string $password
+ Here is the caller graph for this function:

◆ getPort()

ilDBPdo::getPort ( )

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

References $port.

Referenced by generateDSN().

929  : int
930  {
931  return $this->port;
932  }
+ Here is the caller graph for this function:

◆ getPrimaryKeyIdentifier()

ilDBPdo::getPrimaryKeyIdentifier ( )

Implements ilDBInterface.

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

Referenced by addPrimaryKey().

270  : string
271  {
272  return "PRIMARY";
273  }
+ Here is the caller graph for this function:

◆ getSequenceName()

ilDBPdo::getSequenceName ( string  $table_name)

Implements ilDBInterface.

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

References ilDBPdoFieldDefinition\SEQUENCE_FORMAT.

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

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

◆ getServerVersion()

ilDBPdo::getServerVersion ( bool  $native = false)

Implements ilDBPdoInterface.

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

1289  : int
1290  {
1291  return $this->pdo->query('SELECT VERSION()')->fetchColumn();
1292  }

◆ getStorageEngine()

ilDBPdo::getStorageEngine ( )

Implements ilDBInterface.

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

References $storage_engine.

1247  : string
1248  {
1249  return $this->storage_engine;
1250  }
string $storage_engine

◆ getUsername()

ilDBPdo::getUsername ( )

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

References $username.

Referenced by connect().

909  : string
910  {
911  return $this->username;
912  }
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 1491 of file class.ilDBPdo.php.

1491  : string
1492  {
1493  return $this->manager->getQueryUtils()->groupConcat($a_field_name, $a_seperator, $a_order);
1494  }

◆ in()

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

Implements ilDBInterface.

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

References $type.

766  : string
767  {
768  return $this->manager->getQueryUtils()->in($field, $values, $negate, $type);
769  }
$type

◆ indexExistsByFields()

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

Implements ilDBInterface.

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

619  : bool
620  {
621  foreach ($this->manager->listTableIndexes($table_name) as $idx_name) {
622  $def = $this->reverse->getTableIndexDefinition($table_name, $idx_name);
623  $idx_fields = array_keys($def['fields']);
624 
625  if ($idx_fields === $fields) {
626  return true;
627  }
628  }
629 
630  return false;
631  }

◆ initFromIniFile()

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

Implements ilDBInterface.

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

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

133  : void
134  {
135  global $DIC;
136 
137  if ($ini instanceof ilIniFile) {
138  $clientIniFile = $ini;
139  } elseif ($DIC->offsetExists('ilClientIniFile')) {
140  $clientIniFile = $DIC['ilClientIniFile'];
141  } else {
142  throw new InvalidArgumentException('$tmpClientIniFile is not an instance of ilIniFile');
143  }
144 
145  $this->setUsername($clientIniFile->readVariable("db", "user"));
146  $this->setHost($clientIniFile->readVariable("db", "host"));
147  $this->setPort((int) $clientIniFile->readVariable("db", "port"));
148  $this->setPassword((string) $clientIniFile->readVariable("db", "pass"));
149  $this->setDbname($clientIniFile->readVariable("db", "name"));
150  $this->setDBType($clientIniFile->readVariable("db", "type"));
151 
152  $this->generateDSN();
153  }
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 79 of file class.ilDBPdo.php.

Referenced by connect().

79  : void
80  {
81  }
+ 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 437 of file class.ilDBPdo.php.

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

437  : int
438  {
439  $real = array();
440  $fields = array();
441  foreach ($values as $key => $val) {
442  $real[] = $this->quote($val[1], $val[0]);
443  $fields[] = $this->quoteIdentifier($key);
444  }
445  $values_string = implode(",", $real);
446  $fields_string = implode(",", $fields);
447  $query = "INSERT INTO " . $this->quoteIdentifier($table_name) . " (" . $fields_string . ") VALUES (" . $values_string . ")";
448 
450 
451  return (int) $this->pdo->exec($query);
452  }
quote($value, ?string $type=null)
string $key
Consumer key/client ID value.
Definition: System.php:193
$query
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 681 of file class.ilDBPdo.php.

References fetchAssoc(), and query().

681  : bool
682  {
683  $set = $this->query("SHOW INDEX FROM " . $a_table);
684  while ($rec = $this->fetchAssoc($set)) {
685  if ($rec["Key_name"] === $a_name && $rec["Index_type"] === "FULLTEXT") {
686  return true;
687  }
688  }
689 
690  return false;
691  }
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 1195 of file class.ilDBPdo.php.

References $DIC.

1195  : bool
1196  {
1197  global $DIC;
1198  return (new ilDBPdoMySQLFieldDefinition($DIC->database()))->isReserved($a_word);
1199  }
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 827 of file class.ilDBPdo.php.

827  : string
828  {
829  return $this->manager->getQueryUtils()->like($column, $type, $value, $case_insensitive);
830  }
$type

◆ listSequences()

ilDBPdo::listSequences ( )
Returns
string[]

Implements ilDBInterface.

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

Referenced by sequenceExists().

1078  : array
1079  {
1080  return $this->manager->listSequences();
1081  }
+ 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  switch ($module) {
1058  return $this->manager;
1060  return $this->reverse;
1061  }
1062  throw new LogicException('module "' . $module . '" not available');
1063  }
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 1101 of file class.ilDBPdo.php.

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

◆ lockTables()

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

Implements ilDBInterface.

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

750  : void
751  {
752  assert(is_array($tables));
753  $lock = $this->manager->getQueryUtils()->lock($tables);
754  $this->pdo->exec($lock);
755  }

◆ lower()

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

Implements ilDBInterface.

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

970  : string
971  {
972  return " LOWER(" . $expression . ") ";
973  }

◆ manipulate()

ilDBPdo::manipulate ( string  $query)
Exceptions
ilDatabaseException

Implements ilDBInterface.

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

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

Referenced by manipulateF().

547  : int
548  {
549  global $DIC;
550  $ilBench = $DIC['ilBench'] ?? null;
551  try {
553  if ($ilBench instanceof ilBenchmark) {
554  $ilBench->startDbBench($query);
555  }
556  $num_affected_rows = $this->pdo->exec($query);
557  if ($ilBench instanceof ilBenchmark) {
558  $ilBench->stopDbBench();
559  }
560  } catch (PDOException $e) {
561  throw new ilDatabaseException($e->getMessage() . ' QUERY: ' . $query, (int) $e->getCode());
562  }
563 
564  return (int) $num_affected_rows;
565  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$query
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 793 of file class.ilDBPdo.php.

References manipulate(), and quote().

Referenced by replace(), and update().

793  : int
794  {
795  if (!is_array($types) || !is_array($values) || count($types) !== count($values)) {
796  throw new ilDatabaseException("ilDB::manipulateF: types and values must be arrays of same size. ($query)");
797  }
798  $quoted_values = array();
799  foreach ($types as $k => $t) {
800  $quoted_values[] = $this->quote($values[$k], $t);
801  }
802  $query = vsprintf($query, $quoted_values);
803 
804  return $this->manipulate($query);
805  }
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)
$query
+ 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 1312 of file class.ilDBPdo.php.

1312  : array
1313  {
1314  return array();
1315  }

◆ migrateAllTablesToEngine()

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

Implements ilDBPdoInterface.

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

1304  : array
1305  {
1306  return array();
1307  }

◆ modifyTableColumn()

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

Implements ilDBInterface.

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

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

1109  : bool
1110  {
1111  $def = $this->reverse->getTableFieldDefinition($table, $column);
1112 
1113  $analyzer = new ilDBAnalyzer($this);
1114  $best_alt = $analyzer->getBestDefinitionAlternative($def);
1115  $def = $def[$best_alt];
1116  unset($def["nativetype"], $def["mdb2type"]);
1117 
1118  // check attributes
1119  $ilDBPdoFieldDefinition = $this->field_definition;
1120 
1121  $type = $attributes["type"] ?? $def["type"];
1122 
1123  foreach (array_keys($def) as $k) {
1124  if ($k !== "type" && !$ilDBPdoFieldDefinition->isAllowedAttribute($k, $type)) {
1125  unset($def[$k]);
1126  }
1127  }
1128  $check_array = $def;
1129  foreach ($attributes as $k => $v) {
1130  $check_array[$k] = $v;
1131  }
1132  if (!$this->checkColumnDefinition($check_array, true)) {
1133  throw new ilDatabaseException("ilDB Error: modifyTableColumn(" . $table . ", " . $column . ")");
1134  }
1135 
1136  foreach ($attributes as $a => $v) {
1137  $def[$a] = $v;
1138  }
1139 
1140  $attributes["definition"] = $def;
1141 
1142  $changes = array(
1143  "change" => array(
1144  $column => $attributes,
1145  ),
1146  );
1147 
1148  return $this->manager->alterTable($table, $changes, false);
1149  }
$type
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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 835 of file class.ilDBPdo.php.

Referenced by quote().

835  : string
836  {
837  return $this->manager->getQueryUtils()->now();
838  }
+ Here is the caller graph for this function:

◆ numRows()

ilDBPdo::numRows ( ilDBStatement  $statement)

Implements ilDBInterface.

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

References ilDBStatement\rowCount().

579  : int
580  {
581  return $statement->rowCount();
582  }
+ Here is the call graph for this function:

◆ prepare()

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

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

989  : ilDBStatement
990  {
991  return new ilPDOStatement($this->pdo->prepare($query));
992  }
Class ilPDOStatement is a Wrapper Class for PDOStatement.
$query

◆ prepareManip()

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

Implements ilDBInterface.

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

Referenced by update().

984  : ilDBStatement
985  {
986  return new ilPDOStatement($this->pdo->prepare($query));
987  }
Class ilPDOStatement is a Wrapper Class for PDOStatement.
$query
+ Here is the caller graph for this function:

◆ primaryExistsByFields()

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

Implements ilDBInterface.

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

1504  : bool
1505  {
1506  $constraints = $this->manager->listTableConstraints($table_name);
1507 
1508  if (in_array('primary', $constraints)) {
1509  $definitions = $this->reverse->getTableConstraintDefinition($table_name, 'primary');
1510  $primary_fields = array_keys($definitions['fields']);
1511  sort($primary_fields);
1512  sort($fields);
1513 
1514  return $primary_fields === $fields;
1515  }
1516  return false;
1517  }

◆ query()

ilDBPdo::query ( string  $query)
Exceptions
ilDatabaseException

Implements ilDBInterface.

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

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

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

348  : ilDBStatement
349  {
350  global $DIC;
351  $ilBench = $DIC['ilBench'] ?? null;
352 
353  $query = $this->appendLimit($query);
354 
355  try {
356  if ($ilBench instanceof ilBenchmark) {
357  $ilBench->startDbBench($query);
358  }
359  $res = $this->pdo->query($query);
360  if ($ilBench instanceof ilBenchmark) {
361  $ilBench->stopDbBench();
362  }
363  } catch (PDOException $e) {
364  throw new ilDatabaseException($e->getMessage() . ' QUERY: ' . $query, (int) $e->getCode());
365  }
366 
367  $err = $this->pdo->errorCode();
368  if ($err !== PDO::ERR_NONE) {
369  $info = $this->pdo->errorInfo();
370  $info_message = $info[2];
371  throw new ilDatabaseException($info_message . ' QUERY: ' . $query);
372  }
373 
374  return new ilPDOStatement($res);
375  }
$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
$query
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 1252 of file class.ilDBPdo.php.

References $type, ilDBConstants\FETCHMODE_ASSOC, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilDBPdoMySQL\migrateAllTablesToEngine().

1252  : array
1253  {
1254  switch ($type) {
1256  $type = PDO::FETCH_ASSOC;
1257  break;
1259  $type = PDO::FETCH_OBJ;
1260  break;
1261  default:
1262  $type = PDO::FETCH_ASSOC;
1263  break;
1264  }
1265 
1266  return $this->pdo->query($query, PDO::FETCH_ASSOC)->fetchAll(PDO::FETCH_COLUMN, $colnum);
1267  }
$type
$query
+ 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 775 of file class.ilDBPdo.php.

References query(), and quote().

775  : ilDBStatement
776  {
777  if (!is_array($types) || !is_array($values) || count($types) !== count($values)) {
778  throw new ilDatabaseException("ilDB::queryF: Types and values must be arrays of same size. ($query)");
779  }
780  $quoted_values = array();
781  foreach ($types as $k => $t) {
782  $quoted_values[] = $this->quote($values[$k], $t);
783  }
784  $query = vsprintf($query, $quoted_values);
785 
786  return $this->query($query);
787  }
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)
$query
+ 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 1269 of file class.ilDBPdo.php.

References $type, ilDBConstants\FETCHMODE_ASSOC, and ilDBConstants\FETCHMODE_OBJECT.

1273  : array {
1274  switch ($fetchmode) {
1276  $type = PDO::FETCH_ASSOC;
1277  break;
1279  $type = PDO::FETCH_OBJ;
1280  break;
1281  default:
1282  $type = PDO::FETCH_ASSOC;
1283  break;
1284  }
1285 
1286  return $this->pdo->query($query, $type)->fetch();
1287  }
$type
$query

◆ quote()

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

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

References $type, 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().

584  : string
585  {
586  if ($value === null) {
587  return 'NULL';
588  }
589 
590  $pdo_type = PDO::PARAM_STR;
591  switch ($type) {
595  if ($value === '') {
596  return 'NULL';
597  }
598  if ($value === $this->now()) {
599  return $value;
600  }
601  $value = (string) $value;
602  break;
604  return (string) (int) $value;
606  $pdo_type = PDO::PARAM_INT;
607  $value = (string) $value;
608  break;
610  default:
611  $value = (string) $value;
612  $pdo_type = PDO::PARAM_STR;
613  break;
614  }
615 
616  return $this->pdo->quote((string) $value, $pdo_type);
617  }
$type
+ 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 164 of file class.ilDBPdo.php.

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

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

164  : string
165  {
166  return '`' . preg_replace('/[^a-zA-Z0-9_$]/', '', $identifier) . '`';
167  }
+ 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 1159 of file class.ilDBPdo.php.

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

1159  : bool
1160  {
1161  // check table name
1162  try {
1163  $this->checkTableName($new_name);
1164  } catch (ilDatabaseException $e) {
1165  throw new ilDatabaseException(
1166  "ilDB Error: renameTable(" . $name . "," . $new_name . ")<br />" . $e->getMessage(),
1167  $e->getCode()
1168  );
1169  }
1170 
1171  $this->manager->alterTable($name, ["name" => $new_name], false);
1172  if ($this->sequenceExists($name)) {
1173  $this->manager->alterTable(
1174  $this->getSequenceName($name),
1175  ["name" => $this->getSequenceName($new_name)],
1176  false
1177  );
1178  }
1179  // The abstraction_progress is no longer used in ILIAS, see http://www.ilias.de/mantis/view.php?id=19513
1180  // $query = "UPDATE abstraction_progress " . "SET table_name = " . $this->quote($a_new_name, 'text') . " " . "WHERE table_name = "
1181  // . $this->quote($a_name, 'text');
1182  // $this->pdo->query($query);
1183 
1184  return true;
1185  }
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...
if($format !==null) $name
Definition: metadata.php:247
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 410 of file class.ilDBPdo.php.

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

410  : bool
411  {
412  // check table name
413  if (!$this->checkColumnName($column_new_name)) {
414  throw new ilDatabaseException("ilDB Error: renameTableColumn(" . $table_name . "," . $column_old_name . "," . $column_new_name . ")");
415  }
416 
417  $def = $this->reverse->getTableFieldDefinition($table_name, $column_old_name);
418 
419  $analyzer = new ilDBAnalyzer($this);
420  $best_alt = $analyzer->getBestDefinitionAlternative($def);
421  $def = $def[$best_alt];
422  unset($def["nativetype"]);
423  unset($def["mdb2type"]);
424 
425  $f["definition"] = $def;
426  $f["name"] = $column_new_name;
427 
428  $changes = array(
429  "rename" => array(
430  $column_old_name => $f,
431  ),
432  );
433 
434  return $this->manager->alterTable($table_name, $changes, false);
435  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkColumnName(string $a_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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 840 of file class.ilDBPdo.php.

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

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

◆ rollback()

ilDBPdo::rollback ( )
Exceptions

Implements ilDBInterface.

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

References supports().

1228  : bool
1229  {
1230  if (!$this->supports(self::FEATURE_TRANSACTIONS)) {
1231  throw new ilDatabaseException("ilDB::beginTransaction: Transactions are not supported.");
1232  }
1233 
1234  return $this->pdo->rollBack();
1235  }
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 1464 of file class.ilDBPdo.php.

References $query, doesCollationSupportMB4Strings(), and ilDBConstants\MB4_REPLACEMENT.

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

1464  : string
1465  {
1466  if (!$this->doesCollationSupportMB4Strings()) {
1467  $query_replaced = preg_replace(
1468  '/[\x{10000}-\x{10FFFF}]/u',
1470  $query
1471  );
1472  if (!empty($query_replaced)) {
1473  return $query_replaced;
1474  }
1475  }
1476 
1477  return $query;
1478  }
doesCollationSupportMB4Strings()
$query
+ 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 1073 of file class.ilDBPdo.php.

References listSequences().

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

1073  : bool
1074  {
1075  return in_array($sequence, $this->listSequences(), true);
1076  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCharset()

ilDBPdo::setCharset ( string  $charset)

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

References $charset.

904  : void
905  {
906  $this->charset = $charset;
907  }
string $charset

◆ setDBHost()

ilDBPdo::setDBHost ( string  $host)

Implements ilDBInterface.

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

References setHost().

954  : void
955  {
956  $this->setHost($host);
957  }
setHost(string $host)
string $host
+ Here is the call graph for this function:

◆ setDbname()

ilDBPdo::setDbname ( string  $dbname)

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

References $dbname.

Referenced by createDatabase(), and initFromIniFile().

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

◆ setDBPassword()

ilDBPdo::setDBPassword ( string  $password)

Implements ilDBInterface.

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

References setPassword().

949  : void
950  {
951  $this->setPassword($password);
952  }
setPassword(string $password)
string $password
+ Here is the call graph for this function:

◆ setDBPort()

ilDBPdo::setDBPort ( int  $port)

Implements ilDBInterface.

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

References setPort().

944  : void
945  {
946  $this->setPort($port);
947  }
setPort(int $port)
+ Here is the call graph for this function:

◆ setDBType()

ilDBPdo::setDBType ( string  $type)

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

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

Referenced by initFromIniFile().

722  : void
723  {
724  $this->db_type = $type;
725  }
$type
+ 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 939 of file class.ilDBPdo.php.

References setUsername().

939  : void
940  {
941  $this->setUsername($user);
942  }
setUsername(string $username)
+ Here is the call graph for this function:

◆ setFieldDefinition()

ilDBPdo::setFieldDefinition ( \ilDBPdoFieldDefinition  $field_definition)

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

References $field_definition.

103  : void
104  {
105  $this->field_definition = $field_definition;
106  }
ilDBPdoFieldDefinition $field_definition

◆ setHost()

ilDBPdo::setHost ( string  $host)

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

References $host.

Referenced by initFromIniFile(), and setDBHost().

884  : void
885  {
886  $this->host = $host;
887  }
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 818 of file class.ilDBPdo.php.

References $limit, and $offset.

818  : void
819  {
820  $this->limit = $limit;
821  $this->offset = $offset;
822  }

◆ setPassword()

ilDBPdo::setPassword ( string  $password)

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

References $password.

Referenced by initFromIniFile(), and setDBPassword().

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

◆ setPort()

ilDBPdo::setPort ( int  $port)

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

References $port.

Referenced by initFromIniFile(), and setDBPort().

934  : void
935  {
936  $this->port = $port;
937  }
+ Here is the caller graph for this function:

◆ setStorageEngine()

ilDBPdo::setStorageEngine ( string  $storage_engine)

Implements ilDBInterface.

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

References $storage_engine.

1242  : void
1243  {
1244  $this->storage_engine = $storage_engine;
1245  }
string $storage_engine

◆ setUsername()

ilDBPdo::setUsername ( string  $username)

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

References $username.

Referenced by initFromIniFile(), and setDBUser().

914  : void
915  {
916  $this->username = $username;
917  }
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 975 of file class.ilDBPdo.php.

975  : string
976  {
977  $lenstr = "";
978  if ($a_len > -1) {
979  $lenstr = ", " . $a_len;
980  }
981  return " SUBSTR(" . $a_exp . ", " . $a_pos . $lenstr . ") ";
982  }

◆ supports()

ilDBPdo::supports ( string  $feature)

Implements ilDBInterface.

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

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

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

1029  : bool
1030  {
1031  switch ($feature) {
1032  case self::FEATURE_TRANSACTIONS:
1033  return $this->supportsTransactions();
1034  case self::FEATURE_FULLTEXT:
1035  return $this->supportsFulltext();
1036  case self::FEATURE_SLAVE:
1037  return $this->supportsSlave();
1038  default:
1039  return 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 1320 of file class.ilDBPdo.php.

1320  : bool
1321  {
1322  return false;
1323  }

◆ supportsEngineMigration()

ilDBPdo::supportsEngineMigration ( )

Implements ilDBPdoInterface.

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

1325  : bool
1326  {
1327  return false;
1328  }

◆ supportsFulltext()

ilDBPdo::supportsFulltext ( )

Implements ilDBInterface.

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

Referenced by addIndex(), and supports().

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

◆ supportsSlave()

ilDBPdo::supportsSlave ( )

Implements ilDBInterface.

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

Referenced by supports().

1014  : bool
1015  {
1016  return false;
1017  }
+ Here is the caller graph for this function:

◆ supportsTransactions()

ilDBPdo::supportsTransactions ( )

Implements ilDBInterface.

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

Referenced by supports().

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

◆ tableColumnExists()

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

Implements ilDBInterface.

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

References loadModule(), and ilDBConstants\MODULE_MANAGER.

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

◆ tableExists()

ilDBPdo::tableExists ( string  $table_name)

Implements ilDBInterface.

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

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

◆ uniqueConstraintExists()

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

Implements ilDBPdoInterface.

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

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

1403  : bool
1404  {
1405  $analyzer = new ilDBAnalyzer();
1406  $cons = $analyzer->getConstraintsInformation($table);
1407  foreach ($cons as $c) {
1408  if ($c["type"] === "unique" && count($fields) === count($c["fields"])) {
1409  $all_in = true;
1410  foreach ($fields as $f) {
1411  if (!isset($c["fields"][$f])) {
1412  $all_in = false;
1413  }
1414  }
1415  if ($all_in) {
1416  return true;
1417  }
1418  }
1419  }
1420 
1421  return false;
1422  }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ unixTimestamp()

ilDBPdo::unixTimestamp ( )

Implements ilDBPdoInterface.

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

1442  : string
1443  {
1444  return "UNIX_TIMESTAMP()";
1445  }

◆ unlockTables()

ilDBPdo::unlockTables ( )
Exceptions

Implements ilDBInterface.

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

761  : void
762  {
763  $this->pdo->exec($this->manager->getQueryUtils()->unlock());
764  }

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

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

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

◆ upper()

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

Implements ilDBInterface.

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

962  : string
963  {
964  return " UPPER(" . $expression . ") ";
965  }

◆ useSlave()

ilDBPdo::useSlave ( bool  $bool)

TODO.

Implements ilDBInterface.

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

810  : bool
811  {
812  return false;
813  }

Field Documentation

◆ $attributes

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

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

Referenced by getAttributes().

◆ $charset

string ilDBPdo::$charset = 'utf8'
protected

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

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

◆ $db_type

string ilDBPdo::$db_type = ''
protected

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

Referenced by getDBType().

◆ $dbname

string ilDBPdo::$dbname = ''
protected

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

Referenced by getDbname(), and setDbname().

◆ $dsn

string ilDBPdo::$dsn = ''
protected

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

Referenced by getDSN().

◆ $error_code

int ilDBPdo::$error_code = 0
protected

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

Referenced by getLastErrorCode().

◆ $field_definition

ilDBPdoFieldDefinition ilDBPdo::$field_definition = null
protected

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

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

◆ $host

string ilDBPdo::$host = ''
protected

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

Referenced by getHost(), and setHost().

◆ $limit

int ilDBPdo::$limit = null
protected

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

Referenced by appendLimit(), and setLimit().

◆ $manager

ilDBPdoManager ilDBPdo::$manager
protected

◆ $offset

int ilDBPdo::$offset = null
protected

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

Referenced by setLimit().

◆ $options

array ilDBPdo::$options = []

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

Referenced by getAttributes().

◆ $password

string ilDBPdo::$password = ''
protected

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

Referenced by getPassword(), and setPassword().

◆ $pdo

PDO ilDBPdo::$pdo = null
protected

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

◆ $port

int ilDBPdo::$port = 3306
protected

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

Referenced by getPort(), and setPort().

◆ $reverse

ilDBPdoReverse ilDBPdo::$reverse
protected

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

Referenced by loadModule().

◆ $storage_engine

string ilDBPdo::$storage_engine = 'InnoDB'
protected

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

Referenced by getStorageEngine(), and setStorageEngine().

◆ $username

string ilDBPdo::$username = ''
protected

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

Referenced by getUsername(), and setUsername().

◆ FEATURE_FULLTEXT

const ilDBPdo::FEATURE_FULLTEXT = 'fulltext'

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

◆ FEATURE_SLAVE

const ilDBPdo::FEATURE_SLAVE = 'slave'

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

◆ FEATURE_TRANSACTIONS

const ilDBPdo::FEATURE_TRANSACTIONS = 'transactions'

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


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