ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilDBPdoPostgresFieldDefinition Class Reference

Class ilDBPdoPostgresFieldDefinition. More...

+ Inheritance diagram for ilDBPdoPostgresFieldDefinition:
+ Collaboration diagram for ilDBPdoPostgresFieldDefinition:

Public Member Functions

 getTypeDeclaration ($field)
 
- Public Member Functions inherited from ilDBPdoFieldDefinition
 __construct (\ilDBInterface $ilDBInterface)
 ilDBPdoFieldDefinition constructor. More...
 
 checkTableName ($table_name)
 
 isReserved ($table_name)
 
 getAllReserved ()
 
 getReservedMysql ()
 
 setReservedMysql ($reserved_mysql)
 
 getReservedPostgres ()
 
 setReservedPostgres ($reserved_postgres)
 
 checkColumnName ($column_name)
 
 checkIndexName ($a_name)
 
 checkColumnDefinition ($a_def)
 
 isAllowedAttribute ($attribute, $type)
 
 getAvailableTypes ()
 
 setAvailableTypes ($available_types)
 
 getAllowedAttributes ()
 
 setAllowedAttributes ($allowed_attributes)
 
 getMaxLength ()
 
 setMaxLength ($max_length)
 
 getValidTypes ()
 
 convertResult ($value, $type, $rtrim=true)
 
 convertResultRow ($types, $row, $rtrim=true)
 
 getDeclaration ($type, $name, $field)
 
 getTypeDeclaration ($field)
 
 compareDefinition ($current, $previous)
 
 quote ($value, $type=null, $quote=true, $escape_wildcards=false)
 
 writeLOBToFile ($lob, $file)
 
 destroyLOB ($lob)
 
 implodeArray ($array, $type=false)
 
 matchPattern ($pattern, $operator=null, $field=null)
 
 patternEscapeString ()
 
 mapNativeDatatype ($field)
 
 mapPrepareDatatype ($type)
 

Protected Member Functions

 getIntegerDeclaration ($name, $field)
 
 mapNativeDatatypeInternal ($field)
 
- Protected Member Functions inherited from ilDBPdoFieldDefinition
 getQueryUtils ()
 
 getDBInstance ()
 
 checkResultTypes ($types)
 
 baseConvertResult ($value, $type, $rtrim=true)
 
 sortResultFieldTypes ($columns, $types)
 
 getInternalDeclaration ($name, $field)
 
 getDeclarationOptions ($field)
 
 getCharsetFieldDeclaration ($charset)
 
 getCollationFieldDeclaration ($collation)
 
 getIntegerDeclaration ($name, $field)
 
 getTextDeclaration ($name, $field)
 
 getCLOBDeclaration ($name, $field)
 
 getBLOBDeclaration ($name, $field)
 
 getBooleanDeclaration ($name, $field)
 
 getDateDeclaration ($name, $field)
 
 getTimestampDeclaration ($name, $field)
 
 getTimeDeclaration ($name, $field)
 
 getFloatDeclaration ($name, $field)
 
 getDecimalDeclaration ($name, $field)
 
 compareIntegerDefinition ($current, $previous)
 
 compareTextDefinition ($current, $previous)
 
 compareCLOBDefinition ($current, $previous)
 
 compareBLOBDefinition ($current, $previous)
 
 compareDateDefinition ($current, $previous)
 
 compareTimeDefinition ($current, $previous)
 
 compareTimestampDefinition ($current, $previous)
 
 compareBooleanDefinition ($current, $previous)
 
 compareFloatDefinition ($current, $previous)
 
 compareDecimalDefinition ($current, $previous)
 
 quoteInteger ($value, $quote, $escape_wildcards)
 
 quoteText ($value, $quote, $escape_wildcards)
 
 readFile ($value)
 
 quoteLOB ($value, $quote, $escape_wildcards)
 
 quoteCLOB ($value, $quote, $escape_wildcards)
 
 quoteBLOB ($value, $quote, $escape_wildcards)
 
 quoteBoolean ($value, $quote, $escape_wildcards)
 
 quoteDate ($value, $quote, $escape_wildcards)
 
 quoteTimestamp ($value, $quote, $escape_wildcards)
 
 quoteTime ($value, $quote, $escape_wildcards)
 
 quoteFloat ($value, $quote, $escape_wildcards)
 
 quoteDecimal ($value, $quote, $escape_wildcards)
 
 retrieveLOB (&$lob)
 
 readLOB ($lob, $length)
 
 endOfLOB ($lob)
 
 destroyLOBInternal (&$lob)
 
 mapNativeDatatypeInternal ($field)
 

Protected Attributes

 $options
 
- Protected Attributes inherited from ilDBPdoFieldDefinition
 $db_instance
 
 $max_length
 
 $available_types
 
 $reserved_mysql
 
 $reserved_postgres
 
 $query_utils
 
 $valid_default_values
 

Additional Inherited Members

- Data Fields inherited from ilDBPdoFieldDefinition
const DEFAULT_DECIMAL_PLACES = 2
 
const DEFAULT_TEXT_LENGTH = 4000
 
const DEFINITION_COLUMN_NAME = "/^[a-z]+[_a-z0-9]*$/"
 
const DEFINITION_TABLE_NAME = "/^[a-z]+[_a-z0-9]*$/"
 
const INDEX_FORMAT = '%s_idx'
 
const SEQUENCE_COLUMNS_NAME = 'sequence'
 
const SEQUENCE_FORMAT = '%s_seq'
 
const T_BLOB = 'blob'
 
const T_CLOB = 'clob'
 
const T_DATE = 'date'
 
const T_DATETIME = 'datetime'
 
const T_FLOAT = 'float'
 
const T_INTEGER = 'integer'
 
const T_TEXT = 'text'
 
const T_TIME = 'time'
 
const T_TIMESTAMP = 'timestamp'
 
 $allowed_attributes_old
 
 $allowed_attributes
 
- Static Protected Attributes inherited from ilDBPdoFieldDefinition
static $instance
 

Detailed Description

Member Function Documentation

◆ getIntegerDeclaration()

ilDBPdoPostgresFieldDefinition::getIntegerDeclaration (   $name,
  $field 
)
protected
Parameters
$name
$field
Returns
string
Exceptions

ilDatabaseException

Reimplemented from ilDBPdoFieldDefinition.

Definition at line 87 of file class.ilDBPdoPostgresFieldDefinition.php.

88 {
89 $db = $this->getDBInstance();
90
91 if (!empty($field['unsigned'])) {
92 $db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
93 }
94 if (!empty($field['autoincrement'])) {
95 $name = $db->quoteIdentifier($name, true);
96
97 return $name . ' ' . $this->getTypeDeclaration($field);
98 }
99 $default = '';
100 if (array_key_exists('default', $field)) {
101 if ($field['default'] === '') {
102 $field['default'] = empty($field['notnull']) ? null : 0;
103 }
104 $default = ' DEFAULT ' . $this->quote($field['default'], 'integer');
105 } elseif (empty($field['notnull'])) {
106 $default = ' DEFAULT NULL';
107 }
108
109 $notnull = empty($field['notnull']) ? '' : ' NOT NULL';
110 $name = $db->quoteIdentifier($name, true);
111
112 return $name . ' ' . $this->getTypeDeclaration($field) . $default . $notnull;
113 }
quote($value, $type=null, $quote=true, $escape_wildcards=false)
if($format !==null) $name
Definition: metadata.php:230

References $name, ilDBPdoFieldDefinition\getDBInstance(), getTypeDeclaration(), and ilDBPdoFieldDefinition\quote().

+ Here is the call graph for this function:

◆ getTypeDeclaration()

ilDBPdoPostgresFieldDefinition::getTypeDeclaration (   $field)
Parameters
$field
Returns
string

Reimplemented from ilDBPdoFieldDefinition.

Definition at line 23 of file class.ilDBPdoPostgresFieldDefinition.php.

24 {
25 $db = $this->getDBInstance();
26
27 switch ($field['type']) {
28 case 'text':
29 $length = !empty($field['length']) ? $field['length'] : $this->options['default_text_field_length'];
30 $fixed = !empty($field['fixed']) ? $field['fixed'] : false;
31 $fixed = false; // FSX we do not want to have fixed lengths
32
33 return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(' . $this->options['default_text_field_length']
34 . ')') : ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
35 case 'clob':
36 return 'TEXT';
37 case 'blob':
38 return 'BYTEA';
39 case 'integer':
40 if (!empty($field['autoincrement'])) {
41 if (!empty($field['length'])) {
42 $length = $field['length'];
43 if ($length > 4) {
44 return 'BIGSERIAL PRIMARY KEY';
45 }
46 }
47
48 return 'SERIAL PRIMARY KEY';
49 }
50 if (!empty($field['length'])) {
51 $length = $field['length'];
52 if ($length <= 2) {
53 return 'SMALLINT';
54 } elseif ($length == 3 || $length == 4) {
55 return 'INT';
56 } elseif ($length > 4) {
57 return 'BIGINT';
58 }
59 }
60
61 return 'INT';
62 case 'boolean':
63 return 'BOOLEAN';
64 case 'date':
65 return 'DATE';
66 case 'time':
67 return 'TIME without time zone';
68 case 'timestamp':
69 return 'TIMESTAMP without time zone';
70 case 'float':
71 return 'FLOAT8';
72 case 'decimal':
73 $length = !empty($field['length']) ? $field['length'] : 18;
74 $scale = !empty($field['scale']) ? $field['scale'] : $this->options['decimal_places'];
75
76 return 'NUMERIC(' . $length . ',' . $scale . ')';
77 }
78 }

References ilDBPdoFieldDefinition\getDBInstance().

Referenced by getIntegerDeclaration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mapNativeDatatypeInternal()

ilDBPdoPostgresFieldDefinition::mapNativeDatatypeInternal (   $field)
protected
Parameters
$field
Returns
array
Exceptions

ilDatabaseException

Reimplemented from ilDBPdoFieldDefinition.

Definition at line 121 of file class.ilDBPdoPostgresFieldDefinition.php.

122 {
123 $db_type = strtolower($field['type']);
124 $length = $field['length'];
125 $type = array();
126 $unsigned = $fixed = null;
127 switch ($db_type) {
128 case 'smallint':
129 case 'int2':
130 $type[] = 'integer';
131 $unsigned = false;
132 $length = 2;
133 if ($length == '2') {
134 $type[] = 'boolean';
135 if (preg_match('/^(is|has)/', $field['name'])) {
136 $type = array_reverse($type);
137 }
138 }
139 break;
140 case 'int':
141 case 'int4':
142 case 'integer':
143 case 'serial':
144 case 'serial4':
145 $type[] = 'integer';
146 $unsigned = false;
147 $length = 4;
148 break;
149 case 'bigint':
150 case 'int8':
151 case 'bigserial':
152 case 'serial8':
153 $type[] = 'integer';
154 $unsigned = false;
155 $length = 8;
156 break;
157 case 'bool':
158 case 'boolean':
159 $type[] = 'boolean';
160 $length = null;
161 break;
162 case 'text':
163 case 'varchar':
164 $fixed = false;
165 // no break
166 case 'unknown':
167 case 'char':
168 case 'bpchar':
169 $type[] = 'text';
170 if ($length == '1') {
171 $type[] = 'boolean';
172 if (preg_match('/^(is|has)/', $field['name'])) {
173 $type = array_reverse($type);
174 }
175 } elseif (strstr($db_type, 'text')) {
176 $type[] = 'clob';
177 }
178 if ($fixed !== false) {
179 $fixed = true;
180 }
181 break;
182 case 'date':
183 $type[] = 'date';
184 $length = null;
185 break;
186 case 'datetime':
187 case 'timestamp':
188 $type[] = 'timestamp';
189 $length = null;
190 break;
191 case 'time':
192 $type[] = 'time';
193 $length = null;
194 break;
195 case 'float':
196 case 'float8':
197 case 'double':
198 case 'real':
199 $type[] = 'float';
200 break;
201 case 'decimal':
202 case 'money':
203 case 'numeric':
204 $type[] = 'decimal';
205 if ($field['scale']) {
206 $length = $length . ',' . $field['scale'];
207 }
208 break;
209 case 'tinyblob':
210 case 'mediumblob':
211 case 'longblob':
212 case 'blob':
213 case 'bytea':
214 $type[] = 'blob';
215 $length = null;
216 break;
217 case 'oid':
218 $type[] = 'blob';
219 $type[] = 'clob';
220 $length = null;
221 break;
222 case 'year':
223 $type[] = 'integer';
224 $type[] = 'date';
225 $length = null;
226 break;
227 default:
228 throw new ilDatabaseException('unknown database attribute type: ' . $db_type);
229 }
230
231 if ((int) $length <= 0) {
232 $length = null;
233 }
234
235 return array( $type, $length, $unsigned, $fixed );
236 }
Class ilDatabaseException.
$type

References $type.

Field Documentation

◆ $options

ilDBPdoPostgresFieldDefinition::$options
protected
Initial value:
= array(
'default_text_field_length' => 4096,
'decimal_places' => 2,
)

Definition at line 14 of file class.ilDBPdoPostgresFieldDefinition.php.


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