Convert Agile Data field types to SQL field types.

@param string $type    Agile Data field type
@param array  $options More options

@return string
779365
public function getSQLFieldType($type, $options = [])
    {
        $type = strtolower($type);
        $len = null;

        switch ($type) {
            case 'boolean':
                $type = 'tinyint';
                $len = 1;
                break;
            case 'integer':
                $type = 'int';
                break;
            case 'money':
                $type = 'decimal';
                $len = '12,2';
                break;
            case 'float':
                $type = 'decimal';
                $len = '16,6';
                break;
            case 'date':
            case 'datetime':
                $type = 'date';
                break;
            case 'time':
                $type = 'varchar';
                $len = '8';
                break;
            case 'text':
                $type = 'longtext';
                break;
            case 'array':
            case 'object':
                $type = 'longtext';
                break;
            default:
                $type = 'varchar';
                $len = '255';
                break;
        }

        $len = $options['len'] ?? $len;

        return $len !== null ? $type.'('.$len.')' : $type;
    }
623114
public function ensureTypeIsSet(array &$options)
    {
        //if the 'type' option hasn't been set
        if (!isset($options['type'])) {
            //if this is a model and the field is equal to the primary key name, set it as a key field
            if ($this->config->getType() === 'model' && $options['field_name'] === $this->config->getDataModel()->getKeyName()) {
                $options['type'] = 'key';
            }
            //otherwise set it to the default 'text'
            else {
                $options['type'] = 'text';
            }
        }
    }
211189
public function send(string $type, array $options = []): bool
    {
        $type = $this->typeRegistry->get($type);
        $builder = MessageBuilder::fromType($type, $options);
        $message = ResolvedMessage::fromBuilder($builder);

        return $this->driver->send($message);
    }
439476
public function log($type, $data, $options = [])
    {
        if (!$this->config['debug']) {
            return;
        }

        if (is_array($data)) {
            array_walk_recursive($data, function (&$value) {
                if ($value instanceof ObjectID || $value instanceof \MongoDB\BSON\ObjectId) {
                    $value = $value->__toString();
                }
            });
        }

        switch (strtolower($type)) {
            case 'aggregate':
                $this->queryStr = 'runCommand(' . ($data ? json_encode($data) : '') . ');';
                break;
            case 'find':
                $this->queryStr = $type . '(' . ($data ? json_encode($data) : '') . ')';

                if (isset($options['sort'])) {
                    $this->queryStr .= '.sort(' . json_encode($options['sort']) . ')';
                }

                if (isset($options['limit'])) {
                    $this->queryStr .= '.limit(' . $options['limit'] . ')';
                }

                $this->queryStr .= ';';
                break;
            case 'insert':
            case 'remove':
                $this->queryStr = $type . '(' . ($data ? json_encode($data) : '') . ');';
                break;
            case 'update':
                $this->queryStr = $type . '(' . json_encode($options) . ',' . json_encode($data) . ');';
                break;
            case 'cmd':
                $this->queryStr = $data . '(' . json_encode($options) . ');';
                break;
        }

        $this->options = $options;
    }
777052
protected function loadFields($type)
    {
        $options = $this->getUtils()->getOptions();

        $typeMap = $type . 'FieldMap';

        $fields = array();
        foreach ($this->$typeMap as $fieldName => $fieldValue) {
            if (isset($options[$fieldValue])) {
                $fields[$fieldName] = $options[$fieldValue];
            }
        }

        return $fields;
    }
1265831
protected function createFormBuilder($type = FormType::class, $data = null, array $options = [])
    {
        return $this->app['form.factory']->createBuilder($type, $data, $options);
    }
280956
public function setType($type, $options = null)
    {
        $this->type = $type;
        $this->_setCertConfigure();

        return $this;
    }
961647
public static function fromType(TypeInterface $type, array $options = []): self
    {
        $optionsResolver = new OptionsResolver();

        $type->configureOptions($optionsResolver);

        $options = $optionsResolver->resolve($options);

        $builder = new self();

        $type->buildMessage($builder, $options);

        return $builder;
    }
1284384
protected function _handleFlash($type, $options) {
		if (isset($options[$type . 'Message']) && $options[$type . 'Message'] !== false) {
			if (is_string($options[$type . 'Message'])) {
				$flashOptions = [];
				if (isset($options[$type . 'FlashOptions'])) {
					$flashOptions = $options[$type . 'FlashOptions'];
				}

				if (!isset($flashOptions['element'])) {
					if (!$this->_registry->has('Flash')) {
						$this->_registry->load('Flash');
					}

					$flashOptions['element'] = $type;
					$this->_registry->get('Flash')->set($options[$type . 'Message'], $flashOptions);
				}

				return true;
			}
		}

		return false;
	}
367334
public static String getSQLTypeString(int sqlType) {
        switch (sqlType) {
            case Types.ARRAY:
                return "ARRAY (" + sqlType + ')'; 

            case Types.BIGINT:
                return "BIGINT (" + sqlType + ')'; 

            case Types.BINARY:
                return "BINARY (" + sqlType + ')'; 

            case Types.BIT:
                return "BIT (" + sqlType + ')'; 

            case Types.BLOB:
                return "BLOB (" + sqlType + ')'; 

            case Types.BOOLEAN: 
                return "BOOLEAN (" + sqlType + ')'; 

            case Types.CHAR:
                return "CHAR (" + sqlType + ')'; 

            case Types.CLOB:
                return "CLOB (" + sqlType + ')'; 

            case Types.DATALINK: 
                return "DATALINK (" + sqlType + ')'; 

            case Types.DATE:
                return "DATE (" + sqlType + ')'; 

            case Types.DECIMAL:
                return "DECIMAL (" + sqlType + ')'; 

            case Types.DISTINCT:
                return "DISTINCT (" + sqlType + ')'; 

            case Types.DOUBLE:
                return "DOUBLE (" + sqlType + ')'; 

            case Types.FLOAT:
                return "FLOAT (" + sqlType + ')'; 

            case Types.INTEGER:
                return "INTEGER (" + sqlType + ')'; 

            case Types.JAVA_OBJECT:
                return "JAVA OBJECT (" + sqlType + ')'; 

            case Types.LONGNVARCHAR: 
                return "LONGNVARCHAR (" + sqlType + ')'; 

            case Types.LONGVARBINARY:
                return "LONGVARBINARY (" + sqlType + ')'; 

            case Types.LONGVARCHAR:
                return "LONGVARCHAR (" + sqlType + ')'; 

            case Types.NCHAR: 
                return "NCHAR (" + sqlType + ')'; 

            case Types.NCLOB: 
                return "NCLOB (" + sqlType + ')'; 

            case Types.NULL:
                return "NULL (" + sqlType + ')'; 

            case Types.NUMERIC:
                return "NUMERIC (" + sqlType + ')'; 

            case Types.NVARCHAR: 
                return "NVARCHAR (" + sqlType + ')'; 

            case Types.OTHER:
                return "OTHER (" + sqlType + ')'; 

            case Types.REAL:
                return "REAL (" + sqlType + ')'; 

            case Types.REF:
                return "REF (" + sqlType + ')'; 

            case Types.ROWID: 
                return "ROWID (" + sqlType + ')'; 

            case Types.SMALLINT:
                return "SMALLINT (" + sqlType + ')'; 

            case Types.SQLXML: 
                return "SQLXML (" + sqlType + ')'; 

            case Types.STRUCT:
                return "STRUCT (" + sqlType + ')'; 

            case Types.TIME:
                return "TIME (" + sqlType + ')'; 

            case Types.TIMESTAMP:
                return "TIMESTAMP (" + sqlType + ')'; 

            case Types.TINYINT:
                return "TINYINT (" + sqlType + ')'; 

            case Types.VARBINARY:
                return "VARBINARY (" + sqlType + ')'; 

            case Types.VARCHAR:
                return "VARCHAR (" + sqlType + ')'; 
        }

        return "UNKNOWN SQL TYPE (" + sqlType + ')'; 
    }
883757
protected function getGraphQLType(?string $type):?string
    {
        switch ($type) {
            case DoctrineType::BOOLEAN:
                $type = Types::BOOLEAN;
                break;
            case DoctrineType::DECIMAL:
            case DoctrineType::FLOAT:
                $type = Types::FLOAT;
                break;
            case DoctrineType::INTEGER:
            case DoctrineType::BIGINT:
            case DoctrineType::SMALLINT:
                $type = Types::INT;
                break;
            case DoctrineType::STRING:
            case DoctrineType::TEXT:
            case DoctrineType::GUID:
                $type = Types::STRING;
                break;
            case DoctrineType::TARRAY:
            case DoctrineType::SIMPLE_ARRAY:
            case DoctrineType::JSON_ARRAY:
                $type = Types::nonNull(Types::listOf(Types::STRING));
                break;
            case DoctrineType::TIME:
            case DoctrineType::TIME_IMMUTABLE:
                $type = Types::TIME;
                break;
            case DoctrineType::DATE:
                $type = Types::DATE;
                break;
            case DoctrineType::DATETIME:
                $type = Types::DATETIME;
                break;
        }

        return $type;
    }
389540
public function find($type = 'all', $options = []) {
		if ($type === 'first') {
			return parent::find('all', $options)->first();
		}
		if ($type === 'count') {
			return parent::find('all', $options)->count();
		}
		return parent::find($type, $options);
	}
1241491
public function getArrayTypeDeclarationSQL(array $field, array $options)
    {
        $type = array_key_exists('type', $options) ? $options['type'] : Type::STRING;
        return 'ARRAY ( ' . Type::getType($type)->getSQLDeclaration($field, $this) . ' )';
    }
842914
private function is_simple_tableless( $type, array $options ) {
		$field_object = pods_v( $type . '_object', $options );

		return in_array( $field_object, PodsForm::simple_tableless_objects(), true );
	}
464500
public static function dataTypeToEavColumn($type)
    {
        switch ($type) {
            case Property::DATA_TYPE_FLOAT:
                return 'value_float';
                break;

            case Property::DATA_TYPE_BOOLEAN:
            case Property::DATA_TYPE_INTEGER:
                return 'value_integer';
                break;

            case Property::DATA_TYPE_TEXT:
            case Property::DATA_TYPE_PACKED_JSON:
            case Property::DATA_TYPE_INVARIANT_STRING:
                return 'value_text';
                break;

            case Property::DATA_TYPE_STRING:
            default:
                return 'value_string';
                break;
        }
    }
942538
public function setSqlType($sqlType)
    {
        if (!is_string($sqlType)) {
            throw new InvalidArgumentException(
                'SQL Type must be a string.'
            );
        }

        switch (strtoupper($sqlType)) {
            case 'TEXT':
                $sqlType = 'TEXT';
                break;

            case 'TINY':
            case 'TINYTEXT':
                $sqlType = 'TINYTEXT';
                break;

            case 'MEDIUM':
            case 'MEDIUMTEXT':
                $sqlType = 'MEDIUMTEXT';
                break;

            case 'LONG':
            case 'LONGTEXT':
                $sqlType = 'LONGTEXT';
                break;

            default:
                throw new InvalidArgumentException(
                    'SQL Type must be one of TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.'
                );
        }

        $this->sqlType = $sqlType;

        return $this;
    }
572565
private function resolveTypes($type)
    {
        $columnTypes = [];

        do {
            $columnTypes[] = $columnType = $this->columnRegistry[$type];
        } while (($type = $columnType->getParent()) !== null);

        return $columnTypes;
    }