This class gives all kind of DB information using the MDB2 manager and reverse module.
More...
This class gives all kind of DB information using the MDB2 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 147 of file class.ilDBAnalyzer.php.
References array.
148 $fields = $this->manager->listTableFields($a_table);
151 foreach ($fields as $field) {
152 $rdef = $this->reverse->getTableFieldDefinition($a_table, $field);
153 if ($rdef[0][
"autoincrement"]) {
Create styles array
The data for the language used.
◆ getBestDefinitionAlternative()
ilDBAnalyzer::getBestDefinitionAlternative |
( |
|
$a_def | ) |
|
- Parameters
-
- Returns
- int|string
Definition at line 112 of file class.ilDBAnalyzer.php.
References array.
Referenced by getFieldInformation().
129 foreach ($a_def as $k => $rd) {
130 if ($car[$rd[
"type"]] > $cur_car) {
131 $cur_car = $car[$rd[
"type"]];
Create styles array
The data for the language used.
◆ 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 255 of file class.ilDBAnalyzer.php.
References $info, and array.
256 $constraints = $this->manager->listTableConstraints($a_table);
259 foreach ($constraints as $c) {
260 $info = $this->reverse->getTableConstraintDefinition($a_table, $c);
263 if (
$info[
"unique"]) {
265 $i[
"type"] =
"unique";
266 foreach (
$info[
"fields"] as $k => $f) {
267 $i[
"fields"][$k] =
array(
268 "position" => $f[
"position"],
269 "sorting" => $f[
"sorting"],
Create styles array
The data for the language used.
◆ 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 62 of file class.ilDBAnalyzer.php.
References array, and getBestDefinitionAlternative().
63 $fields = $this->manager->listTableFields($a_table);
65 foreach ($fields as $field) {
66 $rdef = $this->reverse->getTableFieldDefinition($a_table, $field);
68 if ($rdef[
"type"] != $rdef[
"mdb2type"]) {
69 throw new ilDatabaseException(
"ilDBAnalyzer::getFielInformation: Found type != mdb2type: $a_table, $field");
77 foreach ($rdef as $k => $rd) {
78 if ($k != $best_alt) {
79 $alt_types .= $rdef[$k][
"type"] . $rdef[$k][
"length"] .
" ";
84 "notnull" => $rdef[$best_alt][
"notnull"],
85 "nativetype" => $rdef[$best_alt][
"nativetype"],
86 "length" => $rdef[$best_alt][
"length"],
87 "unsigned" => $rdef[$best_alt][
"unsigned"],
88 "default" => $rdef[$best_alt][
"default"],
89 "fixed" => $rdef[$best_alt][
"fixed"],
90 "autoincrement" => $rdef[$best_alt][
"autoincrement"],
91 "type" => $rdef[$best_alt][
"type"],
92 "alt_types" => $alt_types,
95 if ($a_remove_not_allowed_attributes) {
96 foreach ($inf[$field] as $k => $v) {
97 if ($k !=
"type" && !in_array($k, $this->allowed_attributes[$inf[$field][
"type"]])) {
98 unset($inf[$field][$k]);
getBestDefinitionAlternative($a_def)
Class ilDatabaseException.
Create styles array
The data for the language used.
◆ 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 199 of file class.ilDBAnalyzer.php.
References $info, and array.
201 $indexes = $this->manager->listTableIndexes($a_table);
204 $mysql_info =
array();
206 $set = $this->il_db->query(
"SHOW INDEX FROM " . $a_table);
207 while ($rec = $this->il_db->fetchAssoc($set)) {
208 if (!empty ($rec[
"Key_name"])) {
209 $mysql_info[$rec[
"Key_name"]] = $rec;
211 $mysql_info[$rec[
"key_name"]] = $rec;
217 foreach ($indexes as $c) {
218 $info = $this->reverse->getTableIndexDefinition($a_table, $c);
221 if (!
$info[
"primary"]) {
223 $i[
"fulltext"] =
false;
224 $suffix = ($a_abstract_table) ?
"_idx" :
"";
226 if ($mysql_info[$i[
"name"]][
"Index_type"] ==
"FULLTEXT" 227 || $mysql_info[$i[
"name"] .
"_idx"][
"Index_type"] ==
"FULLTEXT" 228 || $mysql_info[$i[
"name"]][
"index_type"] ==
"FULLTEXT" 229 || $mysql_info[$i[
"name"] .
"_idx"][
"index_type"] ==
"FULLTEXT" 231 $i[
"fulltext"] =
true;
233 foreach (
$info[
"fields"] as $k => $f) {
234 $i[
"fields"][$k] =
array(
235 "position" => $f[
"position"],
236 "sorting" => $f[
"sorting"],
Create styles array
The data for the language used.
◆ getPrimaryKeyInformation()
ilDBAnalyzer::getPrimaryKeyInformation |
( |
|
$a_table | ) |
|
Get primary key of a table.
- Parameters
-
- Returns
- array primary key information array
Definition at line 168 of file class.ilDBAnalyzer.php.
References $info, and array.
Referenced by hasSequence().
169 $constraints = $this->manager->listTableConstraints($a_table);
172 foreach ($constraints as $c) {
174 $info = $this->reverse->getTableConstraintDefinition($a_table, $c);
176 if (
$info[
"primary"]) {
178 foreach (
$info[
"fields"] as $k => $f) {
179 $pk[
"fields"][$k] =
array(
180 "position" => $f[
"position"],
181 "sorting" => $f[
"sorting"],
Create styles array
The data for the language used.
◆ 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 289 of file class.ilDBAnalyzer.php.
References getPrimaryKeyInformation().
290 $seq = $this->manager->listSequences();
291 if (is_array($seq) && in_array($a_table, $seq)) {
294 if (is_array($pk[
"fields"]) && count($pk[
"fields"] == 1)) {
295 $seq_field = key($pk[
"fields"]);
297 throw new ilDatabaseException(
"ilDBAnalyzer::hasSequence: Error, sequence defined, but no one-field primary key given. Table: " 301 $set = $this->il_db->query(
"SELECT MAX(" .$this->il_db->quoteIdentifier($seq_field) .
") ma FROM " . $this->il_db->quoteIdentifier($a_table) .
"");
302 $rec = $this->il_db->fetchAssoc($set);
303 $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: