lithium\data\source\Database::value PHP 메소드

value() 공개 메소드

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.
또한 보기: 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()`
리턴 mixed value with converted type
    public function value($value, array $schema = array())
    {
        $schema += array('default' => null, 'null' => false);
        if (is_array($value)) {
            foreach ($value as $key => $val) {
                $value[$key] = $this->value($val, isset($schema[$key]) ? $schema[$key] : $schema);
            }
            return $value;
        }
        if (is_object($value) && isset($value->scalar)) {
            return $value->scalar;
        }
        $type = isset($schema['type']) ? $schema['type'] : $this->_introspectType($value);
        $column = isset($this->_columns[$type]) ? $this->_columns[$type] : null;
        return $this->_cast($type, $value, $column, $schema);
    }

Usage Example

 public function value($value, array $schema = array())
 {
     if (($result = parent::value($value, $schema)) !== null) {
         return $result;
     }
     return "'{$value}'";
 }
All Usage Examples Of lithium\data\source\Database::value