lib/Column.php
public function cast($value, $connection)
	{
		if ($value === null)
			return null;

		switch ($this->type)
		{
			case self::STRING:	return (string)$value;
			case self::INTEGER:	return (int)$value;
			case self::DECIMAL:	return (double)$value;
			case self::DATETIME:
			case self::DATE:
				if (!$value)
					return null;

				if ($value instanceof DateTime)
					return $value;

				if ($value instanceof \DateTime)
					return new DateTime($value->format('Y-m-d H:i:s T'));

				return $connection->stringToDateTime($value);
		}
		return $value;
	}
public function cast($value, $connection)
	{
		if ($value === null)
			return null;

		switch ($this->type)
		{
			case self::STRING:	return (string)$value;
			case self::INTEGER:	return (int)$value;
			case self::DECIMAL:	return (double)$value;
			case self::DATETIME:
			case self::DATE:
				if (!$value)
					return null;

				if ($value instanceof DateTime)
					return $value;

				if ($value instanceof \DateTime)
					return new DateTime($value->format('Y-m-d H:i:s T'));

				return $connection->stringToDateTime($value);
		}
		return $value;
	}
public function cast ( $ value , $ connection ) { if ( $ value === null ) return null ; switch ( $ this -> type ) { case self :: STRING : return ( string ) $ value ; case self :: INTEGER : return ( int ) $ value ; case self :: DECIMAL : return ( double ) $ value ; case self :: DATETIME : case self :: DATE : if ( ! $ value ) return null ; if ( $ value instanceof DateTime ) return $ value ; if ( $ value instanceof \ DateTime ) return new DateTime ( $ value -> format ( 'Y-m-d H:i:s T' ) ) ; return $ connection -> stringToDateTime ( $ value ) ; } return $ value ; }
Casts a value to the column's type.

@param mixed $value The value to cast
@param Connection $connection The Connection this column belongs to
@return mixed type-casted value
Casts a value to the column s type .