Class ilDBPdoReverse.
More...
◆ __construct()
ilDBPdoReverse::__construct |
( |
\PDO |
$pdo, |
|
|
ilDBPdo |
$db_instance |
|
) |
| |
◆ getQueryUtils()
ilDBPdoReverse::getQueryUtils |
( |
| ) |
|
◆ getTableConstraintDefinition()
ilDBPdoReverse::getTableConstraintDefinition |
( |
|
$table, |
|
|
|
$constraint_name |
|
) |
| |
- Parameters
-
- Returns
- array
- Exceptions
-
Implements ilDBReverse.
Definition at line 192 of file class.ilDBPdoReverse.php.
References $data, $query, $result, $row, and array.
193 $constraint_name = strtolower($constraint_name);
194 $table = $this->db_instance->quoteIdentifier($table,
true);
195 $query =
"SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */";
197 if (strtolower($constraint_name) !=
'primary') {
198 $constraint_name_pdo = $this->db_instance->getIndexName($constraint_name);
199 $result = $this->db_instance->query(sprintf(
$query, $this->db_instance->quote($constraint_name_pdo)));
204 $constraint_name = strtolower($constraint_name_pdo);
208 $result = $this->db_instance->query(sprintf(
$query, $this->db_instance->quote($constraint_name)));
211 $definition =
array();
214 $row = array_change_key_case(
$row, CASE_LOWER);
215 $key_name =
$row[
'key_name'];
216 if ($this->db_instance->options[
'portability']) {
217 if ($this->db_instance->options[
'field_case'] == CASE_LOWER) {
218 $key_name = strtolower($key_name);
220 $key_name = strtolower($key_name);
223 $key_name = strtolower($key_name);
224 if ($constraint_name == $key_name) {
225 if (
$row[
'non_unique']) {
228 if (
$row[
'key_name'] ==
'PRIMARY') {
229 $definition[
'primary'] =
true;
231 $definition[
'unique'] =
true;
233 $column_name =
$row[
'column_name'];
234 if ($this->db_instance->options[
'portability']) {
235 if ($this->db_instance->options[
'field_case'] == CASE_LOWER) {
236 $column_name = strtolower($column_name);
238 $column_name = strtoupper($column_name);
241 $definition[
'fields'][$column_name] =
array(
242 'position' => $colpos ++,
244 if (!empty(
$row[
'collation'])) {
245 $definition[
'fields'][$column_name][
'sorting'] = (
$row[
'collation'] ==
'A' ?
'ascending' :
'descending');
250 if (empty($definition[
'fields'])) {
Class ilDatabaseException.
Create styles array
The data for the language used.
◆ getTableFieldDefinition()
ilDBPdoReverse::getTableFieldDefinition |
( |
|
$table_name, |
|
|
|
$field_name |
|
) |
| |
- Parameters
-
- Returns
- array
Implements ilDBReverse.
Definition at line 54 of file class.ilDBPdoReverse.php.
References $column, $columns, $data, $query, $res, and array.
58 $table = $this->db_instance->quoteIdentifier($table_name);
59 $query =
"SHOW COLUMNS FROM $table LIKE " . $this->db_instance->quote($field_name);
62 while (
$data =
$res->fetch(PDO::FETCH_ASSOC)) {
66 $ilDBPdoFieldDefinition = $this->db_instance->getFieldDefinition();
69 $column = array_change_key_case($column, CASE_LOWER);
70 $column[
'name'] = $column[
'field'];
71 unset($column[
'field']);
79 $column = array_change_key_case($column, CASE_LOWER);
81 if ($field_name == $column[
'name']) {
82 $mapped_datatype = $ilDBPdoFieldDefinition->mapNativeDatatype($column);
84 list($types, $length, $unsigned, $fixed) = $mapped_datatype;
86 if (empty($column[
'null']) || $column[
'null'] !==
'YES') {
90 if (array_key_exists(
'default', $column)) {
91 $default = $column[
'default'];
92 if (is_null($default) && $notnull) {
96 $autoincrement =
false;
97 if (!empty($column[
'extra']) && $column[
'extra'] ==
'auto_increment') {
98 $autoincrement =
true;
101 $definition[0] =
array(
102 'notnull' => $notnull,
103 'nativetype' => preg_replace(
'/^([a-z]+)[^a-z].*/i',
'\\1', $column[
'type']),
105 if (!is_null($length)) {
106 $definition[0][
'length'] = $length;
108 if (!is_null($unsigned)) {
109 $definition[0][
'unsigned'] = $unsigned;
111 if (!is_null($fixed)) {
112 $definition[0][
'fixed'] = $fixed;
114 if ($default !==
false) {
115 $definition[0][
'default'] = $default;
117 if ($autoincrement !==
false) {
118 $definition[0][
'autoincrement'] = $autoincrement;
120 foreach ($types as $key => $type) {
121 $definition[$key] = $definition[0];
122 if ($type ==
'clob' || $type ==
'blob') {
123 unset($definition[$key][
'default']);
125 $definition[$key][
'type'] = $type;
126 $definition[$key][
'mdb2type'] = $type;
Class ilDatabaseException.
Create styles array
The data for the language used.
◆ getTableIndexDefinition()
ilDBPdoReverse::getTableIndexDefinition |
( |
|
$table, |
|
|
|
$index_name |
|
) |
| |
- Parameters
-
- Returns
- array
- Exceptions
-
Implements ilDBReverse.
Definition at line 143 of file class.ilDBPdoReverse.php.
References $data, $query, $result, $row, and array.
144 $table = $this->db_instance->quoteIdentifier($table,
true);
145 $query =
"SHOW INDEX FROM $table /*!50002 WHERE Key_name = %s */";
146 $index_name_pdo = $this->db_instance->getIndexName($index_name);
147 $result = $this->db_instance->query(sprintf(
$query, $this->db_instance->quote($index_name_pdo)));
151 $index_name = $index_name_pdo;
154 $result = $this->db_instance->query(sprintf(
$query, $this->db_instance->quote($index_name)));
157 $definition =
array();
161 $key_name =
$row[
'key_name'];
164 if ($index_name == $key_name) {
165 if (!
$row[
'non_unique']) {
168 $column_name =
$row[
'column_name'];
169 $definition[
'fields'][$column_name] =
array(
170 'position' => $colpos ++,
172 if (!empty(
$row[
'collation'])) {
173 $definition[
'fields'][$column_name][
'sorting'] = (
$row[
'collation'] ==
'A' ?
'ascending' :
'descending');
178 if (empty($definition[
'fields'])) {
179 throw new ilDatabaseException(
'it was not specified an existing table index (index does not exist)');
Class ilDatabaseException.
Create styles array
The data for the language used.
◆ getTriggerDefinition()
ilDBPdoReverse::getTriggerDefinition |
( |
|
$trigger | ) |
|
◆ tableInfo()
ilDBPdoReverse::tableInfo |
( |
|
$result, |
|
|
|
$mode = null |
|
) |
| |
◆ $db_instance
ilDBPdoReverse::$db_instance |
|
protected |
◆ $pdo
◆ $query_utils
ilDBPdoReverse::$query_utils |
|
protected |
The documentation for this class was generated from the following file: