value() public method

Will bypass any formatters and casting - effectively forcing the engine "to keep its hands off" - when $value is an object with the property scalar (created by casting a scalar value to an object i.e. (object) 'foo'). This feature allows to construct values or queries that are not (yet) supported by the engine.
See also: lithium\data\source\Database::schema()
public value ( mixed $value, array $schema = [] ) : mixed
$value mixed The value to be converted. Arrays will be recursively converted.
$schema array Formatted array from `lithium\data\source\Database::schema()`
return mixed value with converted type
 public function value($value, array $schema = array())
 {
     if (($result = parent::value($value, $schema)) !== null) {
         return $result;
     }
     return "'{$value}'";
 }
示例#2
0
 /**
  * Converts a given value into the proper type based on a given schema definition.
  *
  * @see lithium\data\source\Database::schema()
  * @param mixed $value The value to be converted. Arrays will be recursively converted.
  * @param array $schema Formatted array from `lithium\data\source\Database::schema()`
  * @return mixed Value with converted type.
  */
 public function value($value, array $schema = array())
 {
     if (($result = parent::value($value, $schema)) !== null) {
         return $result;
     }
     return $this->connection->quote((string) $value);
 }
示例#3
0
文件: Sqlite3.php 项目: niel/lithium
	/**
	 * Converts a given value into the proper type based on a given schema definition.
	 *
	 * @link http://www.sqlite.org/lang_keywords.html
	 * @see lithium\data\source\Database::schema()
	 * @param mixed $value The value to be converted. Arrays will be recursively converted.
	 * @param array $schema Formatted array from `lithium\data\source\Database::schema()`
	 * @return mixed Value with converted type.
	 */
	public function value($value, array $schema = array()) {
		if (is_array($value)) {
			return parent::value($value, $schema);
		}
		return "'" . $this->connection->escapeString($value) . "'";
	}
示例#4
0
 /**
  * Converts a given value into the proper type based on a given schema definition.
  *
  * @see lithium\data\source\Database::schema()
  * @param mixed $value The value to be converted. Arrays will be recursively converted.
  * @param array $schema Formatted array from `lithium\data\source\Database::schema()`
  * @return mixed Value with converted type.
  */
 public function value($value, array $schema = array())
 {
     if (($result = parent::value($value, $schema)) !== null) {
         return $result;
     }
     return "'" . mysql_real_escape_string((string) $value, $this->connection) . "'";
 }
示例#5
0
 public function value($value, array $schema = array())
 {
     if (is_array($value)) {
         return parent::value($value, $schema);
     }
     return $value;
 }