lithium\data\source\Database::_introspectType()
Attempts to automatically determine the column type of a value. Used by the value()
method
of various database adapters to determine how to prepare a value if the schema is not
specified.
Parameters
-
mixed
$value
The value to be prepared for an SQL query.
Returns
stringReturns the name of the column type which $value
most likely belongs to.
Source
protected function _introspectType($value) {
switch (true) {
case (is_bool($value)):
return 'boolean';
case (is_float($value) || preg_match('/^\d+\.\d+$/', $value)):
return 'float';
case (is_int($value) || preg_match('/^\d+$/', $value)):
return 'integer';
case (is_string($value) && strlen($value) <= $this->_columns['string']['length']):
return 'string';
default:
return 'text';
}
}