3 declare(strict_types=1);
    32         switch ($field[
'type']) {
    34                 if (empty($field[
'length']) && array_key_exists(
'default', $field)) {
    35                     $field[
'length'] = $db->varchar_max_length ?? null;
    37                 $length = empty($field[
'length']) ? false : $field[
'length'];
    38                 $fixed = empty($field[
'fixed']) ? false : $field[
'fixed'];
    40                     return $length ? 
'CHAR(' . $length . 
')' : 
'CHAR(255)';
    42                 return $length ? 
'VARCHAR(' . $length . 
')' : 
'TEXT';
    45                 if (!empty($field[
'length'])) {
    46                     $length = $field[
'length'];
    51                     if ($length <= 65532) {
    55                     if ($length <= 16_777_215) {
    62                 if (!empty($field[
'length'])) {
    63                     $length = $field[
'length'];
    68                     if ($length <= 65532) {
    72                     if ($length <= 16_777_215) {
    79                 if (!empty($field[
'length'])) {
    80                     $length = $field[
'length'];
   114                 $length = empty($field[
'length']) ? 18 : $field[
'length'];
   115                 $scale = empty($field[
'scale']) ? $db->options[
'decimal_places'] : $field[
'scale'];
   117                 return 'DECIMAL(' . $length . 
',' . $scale . 
')';
   131         $default = $autoinc = 
'';
   132         if (!empty($field[
'autoincrement'])) {
   133             $autoinc = 
' AUTO_INCREMENT PRIMARY KEY';
   134         } elseif (array_key_exists(
'default', $field)) {
   135             if ($field[
'default'] === 
'') {
   136                 $field[
'default'] = empty($field[
'notnull']) ? null : 0;
   138             $default = 
' DEFAULT ' . $this->
quote($field[
'default'], 
'integer');
   139         } elseif (empty($field[
'notnull'])) {
   140             $default = 
' DEFAULT NULL';
   143         $notnull = empty($field[
'notnull']) ? 
'' : 
' NOT NULL';
   144         $unsigned = empty($field[
'unsigned']) ? 
'' : 
' UNSIGNED';
   145         $name = $db->quoteIdentifier($name, 
true);
   147         return $name . 
' ' . $this->
getTypeDeclaration($field) . $unsigned . $default . $notnull . $autoinc;
   156         $db_type = strtolower($field[
'type']);
   157         $db_type = strtok($db_type, 
'(), ');
   158         if ($db_type === 
'national') {
   159             $db_type = strtok(
'(), ');
   161         if (!empty($field[
'length'])) {
   162             $length = strtok($field[
'length'], 
', ');
   163             $decimal = strtok(
', ');
   165             $length = strtok(
'(), ');
   166             $decimal = strtok(
'(), ');
   169         $unsigned = $fixed = null;
   174                 if (preg_match(
'/^(is|has)/', $field[
'name'])) {
   175                     $type = array_reverse($type);
   177                 $unsigned = preg_match(
'/ unsigned/i', $field[
'type']);
   182                 $unsigned = preg_match(
'/ unsigned/i', $field[
'type']);
   187                 $unsigned = preg_match(
'/ unsigned/i', $field[
'type']);
   193                 $unsigned = preg_match(
'/ unsigned/i', $field[
'type']);
   198                 $unsigned = preg_match(
'/ unsigned/i', $field[
'type']);
   211                 if ($length == 
'1') {
   213                     if (preg_match(
'/^(is|has)/', $field[
'name'])) {
   214                         $type = array_reverse($type);
   216                 } elseif (strpos($db_type, 
'text') !== 
false) {
   218                     if ($decimal === 
'binary') {
   222                 if ($fixed !== 
false) {
   228                 preg_match_all(
'/\'.+\'/U', $field[
'type'], $matches);
   231                 if (is_array($matches)) {
   232                     foreach ($matches[0] as $value) {
   233                         $length = max($length, strlen($value) - 2);
   235                     if ($length == 
'1' && count($matches[0]) === 2) {
   237                         if (preg_match(
'/^(is|has)/', $field[
'name'])) {
   238                             $type = array_reverse($type);
   255                 $type[] = 
'timestamp';
   266                 $unsigned = preg_match(
'/ unsigned/i', $field[
'type']);
   272                 $unsigned = preg_match(
'/ unsigned/i', $field[
'type']);
   273                 if ($decimal !== 
false) {
   274                     $length = $length . 
',' . $decimal;
   297         if ((
int) $length <= 0) {
   301         return array( $type, $length, $unsigned, $fixed );
 getTypeDeclaration(array $field)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getIntegerDeclaration(string $name, array $field)
 
mapNativeDatatypeInternal(array $field)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
quote($value, ?string $type=null, bool $quote=true, bool $escape_wildcards=false)