2 require_once(
'class.ilDBPdoFieldDefinition.php');
16 'default_text_field_length' => 4096,
17 'decimal_places' => 2,
28 switch ($field[
'type'])
31 $length = !empty($field[
'length']) ? $field[
'length'] : $this->options[
'default_text_field_length'];
32 $fixed = !empty($field[
'fixed']) ? $field[
'fixed'] :
false;
35 return $fixed ? ($length ?
'CHAR(' . $length .
')' :
'CHAR(' . $this->options[
'default_text_field_length']
36 .
')') : ($length ?
'VARCHAR(' . $length .
')' :
'TEXT');
42 if (!empty($field[
'autoincrement']))
44 if (!empty($field[
'length']))
46 $length = $field[
'length'];
49 return 'BIGSERIAL PRIMARY KEY';
53 return 'SERIAL PRIMARY KEY';
55 if (!empty($field[
'length']))
57 $length = $field[
'length'];
61 } elseif ($length == 3 || $length == 4)
64 } elseif ($length > 4)
76 return 'TIME without time zone';
78 return 'TIMESTAMP without time zone';
82 $length = !empty($field[
'length']) ? $field[
'length'] : 18;
83 $scale = !empty($field[
'scale']) ? $field[
'scale'] : $this->options[
'decimal_places'];
85 return 'NUMERIC(' . $length .
',' . $scale .
')';
100 if (!empty($field[
'unsigned']))
102 $db->warnings[] =
"unsigned integer field \"$name\" is being declared as signed integer";
104 if (!empty($field[
'autoincrement']))
106 $name = $db->quoteIdentifier($name,
true);
111 if (array_key_exists(
'default', $field))
113 if ($field[
'default'] ===
'')
115 $field[
'default'] = empty($field[
'notnull']) ? null : 0;
117 $default =
' DEFAULT ' . $this->
quote($field[
'default'],
'integer');
118 } elseif (empty($field[
'notnull']))
120 $default =
' DEFAULT NULL';
123 $notnull = empty($field[
'notnull']) ?
'' :
' NOT NULL';
124 $name = $db->quoteIdentifier($name,
true);
137 $db_type = strtolower($field[
'type']);
138 $length = $field[
'length'];
140 $unsigned = $fixed = null;
151 if (preg_match(
'/^(is|has)/', $field[
'name']))
153 $type = array_reverse($type);
189 if (preg_match(
'/^(is|has)/', $field[
'name']))
191 $type = array_reverse($type);
193 } elseif (strstr($db_type,
'text'))
197 if ($fixed !==
false)
208 $type[] =
'timestamp';
227 $length = $length .
',' . $field[
'scale'];
252 if ((
int)$length <= 0)
257 return array( $type, $length, $unsigned, $fixed );
quote($value, $type=null, $quote=true, $escape_wildcards=false)
Class ilDBPdoFieldDefinition.
Class ilDBPdoPostgresFieldDefinition.
Class ilDatabaseException.
Create styles array
The data for the language used.
mapNativeDatatypeInternal($field)
getIntegerDeclaration($name, $field)
getTypeDeclaration($field)