lithium\data\source\database\adapter\MySql::_column PHP Méthode

_column() protected méthode

Converts database-layer column types to basic types.
protected _column ( string $real ) : array
$real string Real database-layer column type (i.e. `"varchar(255)"`)
Résultat array Column type (i.e. "string") plus 'length' when appropriate.
    protected function _column($real)
    {
        if (is_array($real)) {
            return $real['type'] . (isset($real['length']) ? "({$real['length']})" : '');
        }
        if (!preg_match('/(?P<type>\\w+)(?:\\((?P<length>[\\d,]+)\\))?/', $real, $column)) {
            return $real;
        }
        $column = array_intersect_key($column, array('type' => null, 'length' => null));
        if (isset($column['length']) && $column['length']) {
            $length = explode(',', $column['length']) + array(null, null);
            $column['length'] = $length[0] ? (int) $length[0] : null;
            $length[1] ? $column['precision'] = (int) $length[1] : null;
        }
        switch (true) {
            case in_array($column['type'], array('date', 'time', 'datetime', 'timestamp')):
                return $column;
            case $column['type'] === 'tinyint' && $column['length'] == '1':
            case $column['type'] === 'boolean':
                return array('type' => 'boolean');
                break;
            case strpos($column['type'], 'int') !== false:
                $column['type'] = 'integer';
                break;
            case strpos($column['type'], 'char') !== false || $column['type'] === 'tinytext':
                $column['type'] = 'string';
                break;
            case strpos($column['type'], 'text') !== false:
                $column['type'] = 'text';
                break;
            case strpos($column['type'], 'blob') !== false || $column['type'] === 'binary':
                $column['type'] = 'binary';
                break;
            case preg_match('/float|double|decimal/', $column['type']):
                $column['type'] = 'float';
                break;
            default:
                $column['type'] = 'text';
                break;
        }
        return $column;
    }