lithium\data\source\Database::_formatters()

protected method

Provide an associative array of Closures to be used as the 'formatter' key inside of the Database::$_columns specification. Each Closure should return the appropriately quoted or unquoted value and accept one or two parameters: $format, the format to apply to value and $value, the value to be formatted.

Example formatter function:

function($format, $value) {
	return is_numeric($value) ? (integer) $value : false;
}

Returns

array

of column types to Closure formatter

Source

	protected function _formatters() {
		$datetime = $timestamp = $date = $time = function($format, $value) {
			if ($format && (($time = strtotime($value)) !== false)) {
				$value = date($format, $time);
			} else {
				return false;
			}
			return $this->connection->quote($value);
		};

		return compact('datetime', 'timestamp', 'date', 'time') + [
			'boolean' => function($value) {
				return $value ? 1 : 0;
			}
		];
	}