Nette\Database\Helpers::detectType PHP Method

detectType() public static method

Heuristic column type detection.
public static detectType ( $type ) : string
return string
    public static function detectType($type)
    {
        static $cache;
        if (!isset($cache[$type])) {
            $cache[$type] = 'string';
            foreach (self::$typePatterns as $s => $val) {
                if (preg_match("#^({$s})\$#i", $type)) {
                    return $cache[$type] = $val;
                }
            }
        }
        return $cache[$type];
    }

Usage Example

Example #1
0
 /**
  * @return array
  */
 protected function getTables()
 {
     $tables = [];
     foreach ($this->structure->getTables() as $table) {
         if ($table['view'] === FALSE) {
             foreach ($this->structure->getColumns($table['name']) as $column) {
                 $tables[$table['name']][$column['name']] = \Nette\Database\Helpers::detectType($column['nativetype']);
             }
         }
     }
     return $tables;
 }
All Usage Examples Of Nette\Database\Helpers::detectType