2 require_once(
'class.ilDBPdoFieldDefinition.php');
16 'default_text_field_length' => 4096,
17 'decimal_places' => 2,
28 switch ($field[
'type']) {
30 $length = !empty($field[
'length']) ? $field[
'length'] : $this->options[
'default_text_field_length'];
31 $fixed = !empty($field[
'fixed']) ? $field[
'fixed'] :
false;
34 return $fixed ? ($length ?
'CHAR(' . $length .
')' :
'CHAR(' . $this->options[
'default_text_field_length']
35 .
')') : ($length ?
'VARCHAR(' . $length .
')' :
'TEXT');
41 if (!empty($field[
'autoincrement'])) {
42 if (!empty($field[
'length'])) {
43 $length = $field[
'length'];
45 return 'BIGSERIAL PRIMARY KEY';
49 return 'SERIAL PRIMARY KEY';
51 if (!empty($field[
'length'])) {
52 $length = $field[
'length'];
55 } elseif ($length == 3 || $length == 4) {
57 } elseif ($length > 4) {
68 return 'TIME without time zone';
70 return 'TIMESTAMP without time zone';
74 $length = !empty($field[
'length']) ? $field[
'length'] : 18;
75 $scale = !empty($field[
'scale']) ? $field[
'scale'] : $this->options[
'decimal_places'];
77 return 'NUMERIC(' . $length .
',' . $scale .
')';
92 if (!empty($field[
'unsigned'])) {
93 $db->warnings[] =
"unsigned integer field \"$name\" is being declared as signed integer";
95 if (!empty($field[
'autoincrement'])) {
101 if (array_key_exists(
'default', $field)) {
102 if ($field[
'default'] ===
'') {
103 $field[
'default'] = empty($field[
'notnull']) ? null : 0;
105 $default =
' DEFAULT ' . $this->
quote($field[
'default'],
'integer');
106 } elseif (empty($field[
'notnull'])) {
110 $notnull = empty($field[
'notnull']) ?
'' :
' NOT NULL';
124 $db_type = strtolower($field[
'type']);
125 $length = $field[
'length'];
127 $unsigned = $fixed = null;
134 if ($length ==
'2') {
136 if (preg_match(
'/^(is|has)/', $field[
'name'])) {
171 if ($length ==
'1') {
173 if (preg_match(
'/^(is|has)/', $field[
'name'])) {
176 } elseif (strstr($db_type,
'text')) {
179 if ($fixed !==
false) {
189 $type[] =
'timestamp';
206 if ($field[
'scale']) {
207 $length = $length .
',' . $field[
'scale'];
232 if ((
int) $length <= 0) {
236 return array(
$type, $length, $unsigned, $fixed );
quote($value, $type=null, $quote=true, $escape_wildcards=false)
Class ilDBPdoFieldDefinition.
Class ilDBPdoPostgresFieldDefinition.
Class ilDatabaseException.
mapNativeDatatypeInternal($field)
getIntegerDeclaration($name, $field)
getTypeDeclaration($field)