private static function extractColumnsFromTableDescription(array $description): array
  {
    $ret = [];

    foreach ($description as $column)
    {
      preg_match('/^(\w+)(.*)?$/', $column['Type'], $parts1);

      $tmp = ['column_name'       => $column['Field'],
              'data_type'         => $parts1[1],
              'numeric_precision' => null,
              'numeric_scale'     => null,
              'dtd_identifier'    => $column['Type']];

      switch ($parts1[1])
      {
        case 'tinyint':
        case 'smallint':
        case 'mediumint':
        case 'int':
        case 'bigint':
          preg_match('/^\((\d+)\)/', $parts1[2], $parts2);
          $tmp['numeric_precision'] = (int)$parts2[1];
          $tmp['numeric_scale']     = 0;
          break;

        case 'year':
          // Nothing to do.
          break;

        case 'float':
          $tmp['numeric_precision'] = 12;
          break;

        case 'double':
          $tmp['numeric_precision'] = 22;
          break;

        case 'binary':
        case 'char':
        case 'varbinary':
        case 'varchar':
          // Nothing to do.
          break;

        case 'decimal':
          preg_match('/^\((\d+),(\d+)\)$/', $parts1[2], $parts2);
          $tmp['numeric_precision'] = (int)$parts2[1];
          $tmp['numeric_scale']     = (int)$parts2[2];;
          break;

        case 'time':
        case 'timestamp':
        case 'date':
        case 'datetime':
          // Nothing to do.
          break;

        case 'enum':
        case 'set':
          // Nothing to do.
          break;

        case 'bit':
          preg_match('/^\((\d+)\)$/', $parts1[2], $parts2);
          $tmp['numeric_precision'] = (int)$parts2[1];
          break;

        case 'tinytext':
        case 'text':
        case 'mediumtext':
        case 'longtext':
        case 'tinyblob':
        case 'blob':
        case 'mediumblob':
        case 'longblob':
          // Nothing to do.
          break;

        default:
          throw new FallenException('data type', $parts1[1]);
      }

      $ret[] = $tmp;
    }

    return $ret;
  }
private static function extractColumnsFromTableDescription(array $description): array
  {
    $ret = [];

    foreach ($description as $column)
    {
      preg_match('/^(\w+)(.*)?$/', $column['Type'], $parts1);

      $tmp = ['column_name'       => $column['Field'],
              'data_type'         => $parts1[1],
              'numeric_precision' => null,
              'numeric_scale'     => null,
              'dtd_identifier'    => $column['Type']];

      switch ($parts1[1])
      {
        case 'tinyint':
        case 'smallint':
        case 'mediumint':
        case 'int':
        case 'bigint':
          preg_match('/^\((\d+)\)/', $parts1[2], $parts2);
          $tmp['numeric_precision'] = (int)$parts2[1];
          $tmp['numeric_scale']     = 0;
          break;

        case 'year':
          // Nothing to do.
          break;

        case 'float':
          $tmp['numeric_precision'] = 12;
          break;

        case 'double':
          $tmp['numeric_precision'] = 22;
          break;

        case 'binary':
        case 'char':
        case 'varbinary':
        case 'varchar':
          // Nothing to do.
          break;

        case 'decimal':
          preg_match('/^\((\d+),(\d+)\)$/', $parts1[2], $parts2);
          $tmp['numeric_precision'] = (int)$parts2[1];
          $tmp['numeric_scale']     = (int)$parts2[2];;
          break;

        case 'time':
        case 'timestamp':
        case 'date':
        case 'datetime':
          // Nothing to do.
          break;

        case 'enum':
        case 'set':
          // Nothing to do.
          break;

        case 'bit':
          preg_match('/^\((\d+)\)$/', $parts1[2], $parts2);
          $tmp['numeric_precision'] = (int)$parts2[1];
          break;

        case 'tinytext':
        case 'text':
        case 'mediumtext':
        case 'longtext':
        case 'tinyblob':
        case 'blob':
        case 'mediumblob':
        case 'longblob':
          // Nothing to do.
          break;

        default:
          throw new FallenException('data type', $parts1[1]);
      }

      $ret[] = $tmp;
    }

    return $ret;
  }
private static function extractColumnsFromTableDescription ( array $ description ) : array { $ ret = [ ] ; foreach ( $ description as $ column ) { preg_match ( '/^(\w+)(.*)?$/' , $ column [ 'Type' ] , $ parts1 ) ; $ tmp = [ 'column_name' => $ column [ 'Field' ] , 'data_type' => $ parts1 [ 1 ] , 'numeric_precision' => null , 'numeric_scale' => null , 'dtd_identifier' => $ column [ 'Type' ] ] ; switch ( $ parts1 [ 1 ] ) { case 'tinyint' : case 'smallint' : case 'mediumint' : case 'int' : case 'bigint' : preg_match ( '/^\((\d+)\)/' , $ parts1 [ 2 ] , $ parts2 ) ; $ tmp [ 'numeric_precision' ] = ( int ) $ parts2 [ 1 ] ; $ tmp [ 'numeric_scale' ] = 0 ; break ; case 'year' : // Nothing to do. break ; case 'float' : $ tmp [ 'numeric_precision' ] = 12 ; break ; case 'double' : $ tmp [ 'numeric_precision' ] = 22 ; break ; case 'binary' : case 'char' : case 'varbinary' : case 'varchar' : // Nothing to do. break ; case 'decimal' : preg_match ( '/^\((\d+),(\d+)\)$/' , $ parts1 [ 2 ] , $ parts2 ) ; $ tmp [ 'numeric_precision' ] = ( int ) $ parts2 [ 1 ] ; $ tmp [ 'numeric_scale' ] = ( int ) $ parts2 [ 2 ] ; ; break ; case 'time' : case 'timestamp' : case 'date' : case 'datetime' : // Nothing to do. break ; case 'enum' : case 'set' : // Nothing to do. break ; case 'bit' : preg_match ( '/^\((\d+)\)$/' , $ parts1 [ 2 ] , $ parts2 ) ; $ tmp [ 'numeric_precision' ] = ( int ) $ parts2 [ 1 ] ; break ; case 'tinytext' : case 'text' : case 'mediumtext' : case 'longtext' : case 'tinyblob' : case 'blob' : case 'mediumblob' : case 'longblob' : // Nothing to do. break ; default : throw new FallenException ( 'data type' , $ parts1 [ 1 ] ) ; } $ ret [ ] = $ tmp ; } return $ ret ; }
Extract column metadata from the rows returend by the SQL statement 'describe table'.

@param array $description The description of the table.

@return array
Extract column metadata from the rows returend by the SQL statement describe table .