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

protected method

Casts a value which is being written or compared to a boolean-type database column.

Parameters

  • mixed $value

    A value of unknown type to be cast to boolean. Numeric values not equal to zero evaluate to true, otherwise false. String values equal to 'true', 't' or 'T' evaluate to true, all others to false. In all other cases, uses PHP's default casting.

Returns

boolean

Returns a boolean representation of $value, based on the comparison rules specified above. Database adapters may override this method if boolean type coercion is required and falls outside the rules defined.

Source

	protected function _toBoolean($value) {
		if (is_bool($value)) {
			return $value;
		}
		if (is_int($value) || is_float($value)) {
			return ($value !== 0);
		}
		if (is_string($value)) {
			return ($value === 't' || $value === 'T' || $value === 'true');
		}
		return (boolean) $value;
	}