public function datatype($type) { static $types = array('blob' => array('type' => 'string', 'binary' => TRUE, 'character_maximum_length' => '65535'), 'bool' => array('type' => 'bool'), 'bigint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '18446744073709551615'), 'datetime' => array('type' => 'string'), 'decimal unsigned' => array('type' => 'float', 'exact' => TRUE, 'min' => '0'), 'double' => array('type' => 'float'), 'double precision unsigned' => array('type' => 'float', 'min' => '0'), 'double unsigned' => array('type' => 'float', 'min' => '0'), 'enum' => array('type' => 'string'), 'fixed' => array('type' => 'float', 'exact' => TRUE), 'fixed unsigned' => array('type' => 'float', 'exact' => TRUE, 'min' => '0'), 'float unsigned' => array('type' => 'float', 'min' => '0'), 'int unsigned' => array('type' => 'int', 'min' => '0', 'max' => '4294967295'), 'integer unsigned' => array('type' => 'int', 'min' => '0', 'max' => '4294967295'), 'longblob' => array('type' => 'string', 'binary' => TRUE, 'character_maximum_length' => '4294967295'), 'longtext' => array('type' => 'string', 'character_maximum_length' => '4294967295'), 'mediumblob' => array('type' => 'string', 'binary' => TRUE, 'character_maximum_length' => '16777215'), 'mediumint' => array('type' => 'int', 'min' => '-8388608', 'max' => '8388607'), 'mediumint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '16777215'), 'mediumtext' => array('type' => 'string', 'character_maximum_length' => '16777215'), 'national varchar' => array('type' => 'string'), 'numeric unsigned' => array('type' => 'float', 'exact' => TRUE, 'min' => '0'), 'nvarchar' => array('type' => 'string'), 'point' => array('type' => 'string', 'binary' => TRUE), 'real unsigned' => array('type' => 'float', 'min' => '0'), 'set' => array('type' => 'string'), 'smallint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '65535'), 'text' => array('type' => 'string', 'character_maximum_length' => '65535'), 'tinyblob' => array('type' => 'string', 'binary' => TRUE, 'character_maximum_length' => '255'), 'tinyint' => array('type' => 'int', 'min' => '-128', 'max' => '127'), 'tinyint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '255'), 'tinytext' => array('type' => 'string', 'character_maximum_length' => '255'), 'year' => array('type' => 'string')); $type = str_replace(' zerofill', '', $type); if (isset($types[$type])) { return $types[$type]; } return parent::datatype($type); }
/** * @link http://www.postgresql.org/docs/current/static/datatype.html#DATATYPE-TABLE */ public function datatype($type) { static $types = array('box' => array('type' => 'string'), 'bytea' => array('type' => 'string', 'binary' => TRUE), 'cidr' => array('type' => 'string'), 'circle' => array('type' => 'string'), 'inet' => array('type' => 'string'), 'int2' => array('type' => 'int', 'min' => '-32768', 'max' => '32767'), 'int4' => array('type' => 'int', 'min' => '-2147483648', 'max' => '2147483647'), 'int8' => array('type' => 'int', 'min' => '-9223372036854775808', 'max' => '9223372036854775807'), 'line' => array('type' => 'string'), 'lseg' => array('type' => 'string'), 'macaddr' => array('type' => 'string'), 'money' => array('type' => 'float', 'exact' => TRUE, 'min' => '-92233720368547758.08', 'max' => '92233720368547758.07'), 'path' => array('type' => 'string'), 'point' => array('type' => 'string'), 'polygon' => array('type' => 'string'), 'text' => array('type' => 'string'), 'tsquery' => array('type' => 'string'), 'tsvector' => array('type' => 'string'), 'uuid' => array('type' => 'string'), 'xml' => array('type' => 'string')); if (isset($types[$type])) { return $types[$type]; } return parent::datatype($type); }
public function datatype($type) { static $types = array('bigint' => array('type' => 'integer'), 'binary' => array('type' => 'string', 'binary' => TRUE), 'bit' => array('type' => 'int'), 'char' => array('type' => 'string'), 'date' => array('type' => 'datetime'), 'datetime' => array('type' => 'datetime'), 'datetime2' => array('type' => 'datetime'), 'datetimeoffset' => array('type' => 'datetime'), 'decimal' => array('type' => 'float', 'exact' => TRUE), 'float' => array('type' => 'float'), 'geography' => array('type' => 'string', 'binary' => TRUE), 'geometry' => array('type' => 'string', 'binary' => TRUE), 'image' => array('type' => 'string', 'binary' => TRUE), 'int' => array('type' => 'int'), 'money' => array('type' => 'string'), 'nchar' => array('type' => 'string'), 'numeric' => array('type' => 'string'), 'nvarchar' => array('type' => 'string'), 'nvarchar(MAX)' => array('type' => 'string', 'binary' => TRUE), 'ntext' => array('type' => 'string', 'binary' => TRUE), 'real' => array('type' => 'float', 'exact' => TRUE), 'smalldatetime' => array('type' => 'datetime'), 'smallint' => array('type' => 'int'), 'smallmoney' => array('type' => 'string'), 'sql_variant' => array('type' => 'string'), 'text' => array('type' => 'string', 'binary' => TRUE), 'time' => array('type' => 'datetime'), 'timestamp' => array('type' => 'string'), 'tinyint' => array('type' => 'int'), 'UDT' => array('type' => 'string', 'binary' => TRUE), 'uniqueidentifier' => array('type' => 'string'), 'varbinary' => array('type' => 'string', 'binary' => TRUE), 'varbinary(MAX)' => array('type' => 'string', 'binary' => TRUE), 'varchar' => array('type' => 'string'), 'varchar(MAX)' => array('type' => 'string', 'binary' => TRUE), 'xml' => array('type' => 'string', 'binary' => TRUE)); $type = str_replace(array(' zerofill', ' identity'), '', $type); if (isset($types[$type])) { return $types[$type]; } return parent::datatype($type); }
public function datatype($datatype) { // The standard MySQL Types static $types = array('bool' => array('type' => 'bool'), 'tinyblob' => array('type' => 'string', 'binary' => TRUE, 'character_maximum_length' => '255'), 'longblob' => array('type' => 'string', 'binary' => TRUE, 'character_maximum_length' => '4294967295'), 'mediumblob' => array('type' => 'string', 'binary' => TRUE, 'character_maximum_length' => '16777215'), 'decimal' => array('type' => 'float', 'exact' => TRUE), 'fixed' => array('type' => 'float', 'exact' => TRUE), 'decimal unsigned' => array('type' => 'float', 'exact' => TRUE, 'min' => '0'), 'numeric unsigned' => array('type' => 'float', 'exact' => TRUE, 'min' => '0'), 'fixed unsigned' => array('type' => 'float', 'exact' => TRUE, 'min' => '0'), 'double' => array('type' => 'float'), 'double precision unsigned' => array('type' => 'float', 'min' => '0'), 'double unsigned' => array('type' => 'float', 'min' => '0'), 'real unsigned' => array('type' => 'float', 'min' => '0'), 'float unsigned' => array('type' => 'float', 'min' => '0'), 'bigint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '18446744073709551615'), 'int unsigned' => array('type' => 'int', 'min' => '0', 'max' => '4294967295'), 'integer unsigned' => array('type' => 'int', 'min' => '0', 'max' => '4294967295'), 'mediumint' => array('type' => 'int', 'min' => '-8388608', 'max' => '8388607'), 'mediumint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '16777215'), 'smallint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '65535'), 'tinyint' => array('type' => 'int', 'min' => '-128', 'max' => '127'), 'tinyint unsigned' => array('type' => 'int', 'min' => '0', 'max' => '255'), 'longtext' => array('type' => 'string', 'character_maximum_length' => '4294967295'), 'mediumtext' => array('type' => 'string', 'character_maximum_length' => '16777215'), 'text' => array('type' => 'string', 'character_maximum_length' => '65535'), 'tinytext' => array('type' => 'string', 'character_maximum_length' => '255'), 'enum' => array('type' => 'string'), 'national varchar' => array('type' => 'string'), 'nvarchar' => array('type' => 'string'), 'set' => array('type' => 'string'), 'datetime' => array('type' => 'datetime', 'format' => 'Y-m-d H:i:s'), 'year' => array('type' => 'datetime', 'format' => 'Y')); // Zerofilled integers shouldnt break this if (strpos($datatype, 'zerofill') !== FALSE) { // Remove it from the datatype $datatype = str_replace(' zerofill', '', $datatype); } // If we can find the datatype return it if (isset($types[$datatype])) { // Return it return $types[$datatype]; } // Otherwise overload it to the parent. return parent::datatype($datatype); }