ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 96 of file class.ilDBPdoPostgresFieldDefinition.php.

97 {
98 $db = $this->getDBInstance();
99
100 if (!empty($field['unsigned']))
101 {
102 $db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
103 }
104 if (!empty($field['autoincrement']))
105 {
106 $name = $db->quoteIdentifier($name, true);
107
108 return $name . ' ' . $this->getTypeDeclaration($field);
109 }
110 $default = '';
111 if (array_key_exists('default', $field))
112 {
113 if ($field['default'] === '')
114 {
115 $field['default'] = empty($field['notnull']) ? null : 0;
116 }
117 $default = ' DEFAULT ' . $this->quote($field['default'], 'integer');
118 } elseif (empty($field['notnull']))
119 {
120 $default = ' DEFAULT NULL';
121 }
122
123 $notnull = empty($field['notnull']) ? '' : ' NOT NULL';
124 $name = $db->quoteIdentifier($name, true);
125
126 return $name . ' ' . $this->getTypeDeclaration($field) . $default . $notnull;
127 }
quote($value, $type=null, $quote=true, $escape_wildcards=false)

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

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

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

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: