ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 
 getReservedOracle ()
 
 setReservedOracle ($reserved_oracle)
 
 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
 
 $reserved_oracle
 
 $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 88 of file class.ilDBPdoPostgresFieldDefinition.php.

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

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 24 of file class.ilDBPdoPostgresFieldDefinition.php.

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

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 122 of file class.ilDBPdoPostgresFieldDefinition.php.

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


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