This class gives all kind of DB information using the database manager and reverse module.
More...
This class gives all kind of DB information using the database manager and reverse module.
- Author
- Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
-
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
- Deprecated:
- Use global ilDB only. If something is missing there, please contact fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Definition at line 16 of file class.ilDBAnalyzer.php.
◆ __construct()
◆ getAutoIncrementField()
ilDBAnalyzer::getAutoIncrementField |
( |
|
$a_table | ) |
|
Gets the auto increment field of a table.
This should be used on ILIAS 3.10.x "MySQL" tables only.
- Parameters
-
- Returns
- string name of autoincrement field
Definition at line 152 of file class.ilDBAnalyzer.php.
154 $fields = $this->manager->listTableFields($a_table);
157 foreach ($fields as $field) {
158 $rdef = $this->reverse->getTableFieldDefinition($a_table, $field);
159 if ($rdef[0][
"autoincrement"]) {
◆ getBestDefinitionAlternative()
ilDBAnalyzer::getBestDefinitionAlternative |
( |
|
$a_def | ) |
|
- Parameters
-
- Returns
- int|string
Definition at line 116 of file class.ilDBAnalyzer.php.
Referenced by getFieldInformation().
134 foreach ($a_def as $k => $rd) {
135 if ($car[$rd[
"type"]] > $cur_car) {
136 $cur_car = $car[$rd[
"type"]];
◆ getConstraintsInformation()
ilDBAnalyzer::getConstraintsInformation |
( |
|
$a_table, |
|
|
|
$a_abstract_table = false |
|
) |
| |
Get information on constraints of a table.
Primary key is NOT included! Fulltext indices are included and marked.
- Parameters
-
- Returns
- array indices information array
Definition at line 262 of file class.ilDBAnalyzer.php.
References $c, $f, $i, and $info.
264 $constraints = $this->manager->listTableConstraints($a_table);
267 foreach ($constraints as
$c) {
268 $info = $this->reverse->getTableConstraintDefinition($a_table, $c);
271 if (
$info[
"unique"]) {
273 $i[
"type"] =
"unique";
274 foreach (
$info[
"fields"] as $k =>
$f) {
275 $i[
"fields"][$k] = array(
276 "position" =>
$f[
"position"],
277 "sorting" =>
$f[
"sorting"],
◆ getFieldInformation()
ilDBAnalyzer::getFieldInformation |
( |
|
$a_table, |
|
|
|
$a_remove_not_allowed_attributes = false |
|
) |
| |
Get field information of a table.
- Parameters
-
- Returns
- array field information array
Definition at line 65 of file class.ilDBAnalyzer.php.
References getBestDefinitionAlternative().
67 $fields = $this->manager->listTableFields($a_table);
69 foreach ($fields as $field) {
70 $rdef = $this->reverse->getTableFieldDefinition($a_table, $field);
72 if ($rdef[
"type"] != $rdef[
"mdb2type"]) {
73 throw new ilDatabaseException(
"ilDBAnalyzer::getFielInformation: Found type != mdb2type: $a_table, $field");
81 foreach ($rdef as $k => $rd) {
82 if ($k != $best_alt) {
83 $alt_types .= $rdef[$k][
"type"] . $rdef[$k][
"length"] .
" ";
88 "notnull" => $rdef[$best_alt][
"notnull"],
89 "nativetype" => $rdef[$best_alt][
"nativetype"],
90 "length" => $rdef[$best_alt][
"length"],
91 "unsigned" => $rdef[$best_alt][
"unsigned"],
92 "default" => $rdef[$best_alt][
"default"],
93 "fixed" => $rdef[$best_alt][
"fixed"],
94 "autoincrement" => $rdef[$best_alt][
"autoincrement"],
95 "type" => $rdef[$best_alt][
"type"],
96 "alt_types" => $alt_types,
99 if ($a_remove_not_allowed_attributes) {
100 foreach ($inf[$field] as $k => $v) {
101 if ($k !=
"type" && !in_array($k, $this->allowed_attributes[$inf[$field][
"type"]])) {
102 unset($inf[$field][$k]);
getBestDefinitionAlternative($a_def)
Class ilDatabaseException.
◆ getIndicesInformation()
ilDBAnalyzer::getIndicesInformation |
( |
|
$a_table, |
|
|
|
$a_abstract_table = false |
|
) |
| |
Get information on indices of a table.
Primary key is NOT included! Fulltext indices are included and marked.
- Parameters
-
- Returns
- array indices information array
Definition at line 205 of file class.ilDBAnalyzer.php.
References $c, $f, $i, and $info.
208 $indexes = $this->manager->listTableIndexes($a_table);
211 $mysql_info = array();
213 $set = $this->il_db->query(
"SHOW INDEX FROM " . $a_table);
214 while ($rec = $this->il_db->fetchAssoc($set)) {
215 if (!empty($rec[
"Key_name"])) {
216 $mysql_info[$rec[
"Key_name"]] = $rec;
218 $mysql_info[$rec[
"key_name"]] = $rec;
224 foreach ($indexes as
$c) {
225 $info = $this->reverse->getTableIndexDefinition($a_table, $c);
228 if (!
$info[
"primary"]) {
230 $i[
"fulltext"] =
false;
231 $suffix = ($a_abstract_table) ?
"_idx" :
"";
233 if ($mysql_info[
$i[
"name"]][
"Index_type"] ==
"FULLTEXT" 234 || $mysql_info[
$i[
"name"] .
"_idx"][
"Index_type"] ==
"FULLTEXT" 235 || $mysql_info[
$i[
"name"]][
"index_type"] ==
"FULLTEXT" 236 || $mysql_info[
$i[
"name"] .
"_idx"][
"index_type"] ==
"FULLTEXT" 238 $i[
"fulltext"] =
true;
240 foreach (
$info[
"fields"] as $k =>
$f) {
241 $i[
"fields"][$k] = array(
242 "position" =>
$f[
"position"],
243 "sorting" =>
$f[
"sorting"],
◆ getPrimaryKeyInformation()
ilDBAnalyzer::getPrimaryKeyInformation |
( |
|
$a_table | ) |
|
Get primary key of a table.
- Parameters
-
- Returns
- array primary key information array
Definition at line 174 of file class.ilDBAnalyzer.php.
References $c, $f, and $info.
Referenced by hasSequence().
176 $constraints = $this->manager->listTableConstraints($a_table);
179 foreach ($constraints as
$c) {
180 $info = $this->reverse->getTableConstraintDefinition($a_table, $c);
182 if (
$info[
"primary"]) {
184 foreach (
$info[
"fields"] as $k =>
$f) {
185 $pk[
"fields"][$k] = array(
186 "position" =>
$f[
"position"],
187 "sorting" =>
$f[
"sorting"],
◆ hasSequence()
ilDBAnalyzer::hasSequence |
( |
|
$a_table | ) |
|
Check whether sequence is defined for current table (only works on "abstraced" tables)
- Parameters
-
- Returns
- mixed false, if no sequence is defined, start number otherwise
- Exceptions
-
Definition at line 297 of file class.ilDBAnalyzer.php.
References getPrimaryKeyInformation().
299 $seq = $this->manager->listSequences();
300 if (is_array($seq) && in_array($a_table, $seq)) {
303 if (is_array($pk[
"fields"]) && count($pk[
"fields"] == 1)) {
304 $seq_field = key($pk[
"fields"]);
306 throw new ilDatabaseException(
"ilDBAnalyzer::hasSequence: Error, sequence defined, but no one-field primary key given. Table: " 310 $set = $this->il_db->query(
"SELECT MAX(" . $this->il_db->quoteIdentifier($seq_field) .
") ma FROM " . $this->il_db->quoteIdentifier($a_table) .
"");
311 $rec = $this->il_db->fetchAssoc($set);
312 $next = $rec[
"ma"] + 1;
Class ilDatabaseException.
getPrimaryKeyInformation($a_table)
Get primary key of a table.
◆ $allowed_attributes
ilDBAnalyzer::$allowed_attributes |
|
protected |
◆ $il_db
◆ $manager
◆ $reverse
The documentation for this class was generated from the following file: