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
コード例 #1
0
 public function value($value, array $schema = array())
 {
     if (($result = parent::value($value, $schema)) !== null) {
         return $result;
     }
     return "'{$value}'";
 }
コード例 #2
0
ファイル: PostgreSql.php プロジェクト: fedeisas/lithium
 /**
  * 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
ファイル: MySql.php プロジェクト: WarToaster/HangOn
 /**
  * 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
ファイル: MockAdapter.php プロジェクト: fedeisas/lithium
 public function value($value, array $schema = array())
 {
     if (is_array($value)) {
         return parent::value($value, $schema);
     }
     return $value;
 }