Returns Phinx type by SQL type

@param string $sqlType SQL type
@return string Phinx type
@throws UnsupportedColumnTypeException
760295
public function getPhinxType($sqlType)
    {
        switch ($sqlType) {
            case 'character varying':
            case 'varchar':
                return static::PHINX_TYPE_STRING;
            case 'character':
            case 'char':
                return static::PHINX_TYPE_CHAR;
            case 'text':
                return static::PHINX_TYPE_TEXT;
            case 'json':
                return static::PHINX_TYPE_JSON;
            case 'jsonb':
                return static::PHINX_TYPE_JSONB;
            case 'smallint':
                return static::PHINX_TYPE_SMALL_INTEGER;
            case 'int':
            case 'int4':
            case 'integer':
                return static::PHINX_TYPE_INTEGER;
            case 'decimal':
            case 'numeric':
                return static::PHINX_TYPE_DECIMAL;
            case 'bigint':
            case 'int8':
                return static::PHINX_TYPE_BIG_INTEGER;
            case 'real':
            case 'float4':
                return static::PHINX_TYPE_FLOAT;
            case 'double precision':
                return static::PHINX_TYPE_DOUBLE;
            case 'bytea':
                return static::PHINX_TYPE_BINARY;
            case 'interval':
                return static::PHINX_TYPE_INTERVAL;
            case 'time':
            case 'timetz':
            case 'time with time zone':
            case 'time without time zone':
                return static::PHINX_TYPE_TIME;
            case 'date':
                return static::PHINX_TYPE_DATE;
            case 'timestamp':
            case 'timestamptz':
            case 'timestamp with time zone':
            case 'timestamp without time zone':
                return static::PHINX_TYPE_DATETIME;
            case 'bool':
            case 'boolean':
                return static::PHINX_TYPE_BOOLEAN;
            case 'uuid':
                return static::PHINX_TYPE_UUID;
            case 'cidr':
                return static::PHINX_TYPE_CIDR;
            case 'inet':
                return static::PHINX_TYPE_INET;
            case 'macaddr':
                return static::PHINX_TYPE_MACADDR;
            default:
                throw new UnsupportedColumnTypeException('Column type "' . $sqlType . '" is not supported by Postgresql.');
        }
    }
276553
protected function getMySQLColumnType($columnData)
    {
        $type = $columnData['COLUMN_TYPE'];
        $pattern = '/^[a-z]+/';
        $match = null;
        preg_match($pattern, $type, $match);

        return $match[0];
    }
1086303
private function sqlsrvtype2moodletype($sqlsrv_type) {
        $type = null;

        switch (strtoupper($sqlsrv_type)) {
          case 'BIT':
           $type = 'L';
           break;

          case 'INT':
          case 'SMALLINT':
          case 'INTEGER':
          case 'BIGINT':
           $type = 'I';
           break;

          case 'DECIMAL':
          case 'REAL':
          case 'FLOAT':
           $type = 'N';
           break;

          case 'VARCHAR':
          case 'NVARCHAR':
           $type = 'C';
           break;

          case 'TEXT':
          case 'NTEXT':
          case 'VARCHAR(MAX)':
          case 'NVARCHAR(MAX)':
           $type = 'X';
           break;

          case 'IMAGE':
          case 'VARBINARY':
          case 'VARBINARY(MAX)':
           $type = 'B';
           break;

          case 'DATETIME':
           $type = 'D';
           break;
         }

        if (!$type) {
            throw new dml_exception('invalidsqlsrvnativetype', $sqlsrv_type);
        }
        return $type;
    }
607879
public function column( $type )
    {
        $classPrefix = __CLASS__ . '\\Type\\';

        if ( is_string( $type ) &&
             class_exists( $classPrefix . ucfirst( $type ) ) )
        {
            $type = ucfirst( $type );
            $args = func_get_args();
            array_shift( $args );
        }
        else if ( is_callable( $type ) )
        {
            $args = func_get_args();
            $type = static::CALLBACK;
        }
        else
        {
            $type = ucfirst( (string) $type );
            $args = func_get_args();
            array_shift( $args );
        }

        $class = $classPrefix . $type;

        if ( ! class_exists( $class ) )
        {
            throw new \LogicException( 'RowSet-type does not exists: ' . $class );
        }

        $reflection = new \ReflectionClass( $class );
        $result     = $reflection->newInstanceArgs( $args );

        if ( $result instanceof HelperInterface )
        {
            $result->setView( $this->getView() );
        }

        return $result;
    }
641568
public static int toSQLType(String strType) throws DatabaseException {
	strType = strType.toUpperCase().trim();
	if (strType.startsWith("CF_SQL_")) strType = strType.substring(7);
	if (strType.startsWith("SQL_")) strType = strType.substring(4);

	if (strType.length() > 2) {
	    char first = strType.charAt(0);
	    if (first == 'A') {
		if (strType.equals("ARRAY")) return Types.ARRAY;
	    }
	    else if (first == 'B') {
		if (strType.equals("BIGINT")) return Types.BIGINT;
		else if (strType.equals("BINARY")) return Types.BINARY;
		else if (strType.equals("BIT")) return Types.BIT;
		else if (strType.equals("BLOB")) return Types.BLOB;
		else if (strType.equals("BOOLEAN")) return Types.BOOLEAN;
		else if (strType.equals("BOOL")) return Types.BOOLEAN;
	    }
	    else if (first == 'C') {
		if (strType.equals("CLOB")) return Types.CLOB;
		else if (strType.equals("CHAR")) return Types.CHAR;
		else if (strType.equals("CLOB")) return Types.CLOB;
		else if (strType.equals("CURSOR")) return CFTypes.CURSOR;
	    }
	    else if (first == 'D') {
		if (strType.equals("DATALINK")) return Types.DATALINK;
		else if (strType.equals("DATE")) return Types.DATE;
		else if (strType.equals("DISTINCT")) return Types.DISTINCT;
		else if (strType.equals("DECIMAL")) return Types.DECIMAL;
		else if (strType.equals("DOUBLE")) return Types.DOUBLE;
	    }
	    else if (first == 'F') {
		if (strType.equals("FLOAT")) return Types.FLOAT;
	    }
	    else if (first == 'I') {
		if (strType.equals("IDSTAMP")) return CFTypes.IDSTAMP;
		else if (strType.equals("INTEGER")) return Types.INTEGER;
		else if (strType.equals("INT")) return Types.INTEGER;
	    }
	    else if (first == 'L') {
		// if(strType.equals("LONG"))return Types.INTEGER;
		if (strType.equals("LONGVARBINARY")) return Types.LONGVARBINARY;
		else if (strType.equals("LONGVARCHAR")) return Types.LONGVARCHAR;
	    }
	    else if (first == 'M') {
		if (strType.equals("MONEY")) return Types.DOUBLE;
		else if (strType.equals("MONEY4")) return Types.DOUBLE;
	    }
	    else if (first == 'N') {
		if (strType.equals("NUMERIC")) return Types.NUMERIC;
		else if (strType.equals("NUMBER")) return Types.NUMERIC;
		else if (strType.equals("NULL")) return Types.NULL;
		else if (strType.equals("NCHAR")) return Types.NCHAR;
		else if (strType.equals("NCLOB")) return Types.NCLOB;
		else if (strType.equals("NVARCHAR")) return Types.NVARCHAR;

	    }
	    else if (first == 'O') {
		if (strType.equals("OTHER")) return Types.OTHER;
		else if ("OBJECT".equals(strType)) return Types.OTHER;
	    }
	    else if (first == 'R') {
		if (strType.equals("REAL")) return Types.REAL;
		else if (strType.equals("REF")) return Types.REF;
		else if (strType.equals("REFCURSOR")) return CFTypes.CURSOR;
	    }
	    else if (first == 'S') {
		if (strType.equals("SMALLINT")) return Types.SMALLINT;
		else if (strType.equals("STRUCT")) return Types.STRUCT;
		else if (strType.equals("STRING")) return Types.VARCHAR;
		else if (strType.equals("SQLXML")) return Types.SQLXML;
	    }
	    else if (first == 'T') {
		if (strType.equals("TIME")) return Types.TIME;
		else if (strType.equals("TIMESTAMP")) return Types.TIMESTAMP;
		else if (strType.equals("TINYINT")) return Types.TINYINT;
	    }
	    else if (first == 'V') {
		if (strType.equals("VARBINARY")) return Types.VARBINARY;
		else if (strType.equals("VARCHAR")) return Types.VARCHAR;
		else if (strType.equals("VARCHAR2")) return CFTypes.VARCHAR2;
	    }
	}

	throw new DatabaseException("invalid CF SQL Type [" + strType + "]", null, null, null);
    }
559739
public function getResultingType() : \Dms\Core\Persistence\Db\Schema\Type\Type
    {
        if (in_array($this->operator, [self::ADD, self::SUBTRACT])) {
            return $this->left->getResultingType();
        } else {
            return new Boolean();
        }
    }
436118
def getTypeInfo(self, sql_type):  # nopep8
        
        fut = self._run_operation(self._impl.getTypeInfo, sql_type)
        return fut
262975
public function getXMLDBKeyType($type) {

        $result = XMLDB_KEY_INCORRECT;

        switch (strtolower($type)) {
            case 'primary':
                $result = XMLDB_KEY_PRIMARY;
                break;
            case 'unique':
                $result = XMLDB_KEY_UNIQUE;
                break;
            case 'foreign':
                $result = XMLDB_KEY_FOREIGN;
                break;
            case 'foreign-unique':
                $result = XMLDB_KEY_FOREIGN_UNIQUE;
                break;
            // case 'check':  //Not supported
            //     $result = XMLDB_KEY_CHECK;
            //     break;
        }
        // Return the normalized XMLDB_KEY
        return $result;
    }
793716
protected function supportedType($type)
    {
        $supportedType = false;

        $baseType = substr($type, 0, strpos($type, '-'));

        if (array_key_exists($baseType, $this->supportedTypes)) {
            $supportedType = $baseType;
        }

        return $supportedType;
    }
1044630
protected function getPhinxColumnOptions($phinxType, $columnData, $columns)
    {
        $attributes = [];

        $attributes = $this->getPhinxColumnOptionsNull($attributes, $columnData);

        // default value
        $attributes = $this->getPhinxColumnOptionsDefault($attributes, $columnData);

        // For timestamp columns:
        $attributes = $this->getPhinxColumnOptionsTimestamp($attributes, $columnData);

        // limit / length
        $attributes = $this->getPhinxColumnOptionsLimit($attributes, $columnData);

        // numeric attributes
        $attributes = $this->getPhinxColumnOptionsNumeric($attributes, $columnData);

        // enum values
        if ($phinxType === 'enum') {
            $attributes = $this->getOptionEnumValue($attributes, $columnData);
        }

        // Collation
        $attributes = $this->getPhinxColumnCollation($phinxType, $attributes, $columnData);

        // Encoding
        $attributes = $this->getPhinxColumnEncoding($phinxType, $attributes, $columnData);

        // Comment
        $attributes = $this->getPhinxColumnOptionsComment($attributes, $columnData);

        // after: specify the column that a new column should be placed after
        $attributes = $this->getPhinxColumnOptionsAfter($attributes, $columnData, $columns);

        // @todo
        // update set an action to be triggered when the row is updated (use with CURRENT_TIMESTAMP)
        //
        // For foreign key definitions:
        // update set an action to be triggered when the row is updated
        // delete set an action to be triggered when the row is deleted

        $result = '[' . implode(', ', $attributes) . ']';

        return $result;
    }
1000936
public function getParamType($fieldType)
	{
		$fieldType = strtolower($fieldType);
		return isset($this->paramType[$fieldType]) ? $this->paramType[$fieldType] : PDO::PARAM_STR;
	}
977761
public function getColumnType()
    {
        if (!($type = $this->links->get('simpleType'))) {
            $type = $this->links->get('userType');
        }

        return $type;
    }
17684
public function getPhinxType($sqlTypeDef)
    {
        if (!preg_match('/^([\w]+)(\(([\d]+)*(,([\d]+))*\))*$/', $sqlTypeDef, $matches)) {
            throw new \RuntimeException('Column type ' . $sqlTypeDef . ' is not supported');
        }

        $limit = null;
        $precision = null;
        $type = $matches[1];
        if (count($matches) > 2) {
            $limit = $matches[3] ?: null;
        }
        if (count($matches) > 4) {
            $precision = $matches[5];
        }
        switch ($matches[1]) {
            case 'varchar':
                $type = static::PHINX_TYPE_STRING;
                if ($limit === 255) {
                    $limit = null;
                }
                break;
            case 'char':
                $type = static::PHINX_TYPE_CHAR;
                if ($limit === 255) {
                    $limit = null;
                }
                if ($limit === 36) {
                    $type = static::PHINX_TYPE_UUID;
                }
                break;
            case 'int':
                $type = static::PHINX_TYPE_INTEGER;
                if ($limit === 11) {
                    $limit = null;
                }
                break;
            case 'bigint':
                if ($limit === 11) {
                    $limit = null;
                }
                $type = static::PHINX_TYPE_BIG_INTEGER;
                break;
            case 'blob':
                $type = static::PHINX_TYPE_BINARY;
                break;
        }
        if ($type === 'tinyint') {
            if ($matches[3] === 1) {
                $type = static::PHINX_TYPE_BOOLEAN;
                $limit = null;
            }
        }

        $this->getSqlType($type);

        return [
            'name' => $type,
            'limit' => $limit,
            'precision' => $precision,
        ];
    }
970597
function GetPhpType()
	{
		$rt = $this->Type;
		switch ($this->Type)
		{
			case "smallint":
			case "bigint":
			case "tinyint":
			case "mediumint":
				$rt = "int";
				break;
			case "varchar":
			case "text":
			case "tinytext":
				$rt = "string";
				break;
			case "date":
			case "datetime":
				$rt = "date";
				break;
			case "decimal":
			case "float":
				$rt = "float";
				break;
			default;
				break;
		}

		return $rt;
	}
533653
public function getPDOParamType($type)
	{
		switch($type)
		{
			case 'b':
				return PDO::PARAM_BOOL;
			case 'd':
				return PDO::PARAM_INT;
			case 'l':
				return PDO::PARAM_LOB;
			default:
				return PDO::PARAM_STR;
		}
	}
395250
protected function getTimestampByColumnType($columnType) {
		return isset(self::$map[$columnType]) ? new CDbExpression(self::$map[$columnType]) : time();
	}
412142
public function getColumnType($table, $column)
    {
        $table = $this->connection->getTablePrefix().$table;

        return $this->connection->getDoctrineColumn($table, $column)->getType()->getName();
    }