Creates a {@link Value} from the value i.e., a {@link TextValue} for a
value of type {@code string}, {@link BooleanValue} for type {@code bool},
{@link NumberValue} for type {@code float}, or {@code int},
{@link DateTimeValue} for type {@link DfpDateTime}, {@link DateValue} for
type {@link Date}, and {@link SetValue} for type {@code array}. If the
value is a {@code Value}, the value is returned. If the value is
{@code null}, an empty {@link TextValue} is returned.
public static CreateValue ( mixed $value ) : Value | ||
$value | mixed | the value to convert |
return | Value | the constructed value of the appropriate type |
/** * Adds a value to the statement in the form of a {@code Value}. * * @param string $key the value key * @param mixed $value the value either as a primitive, which will be * converted to a PQL Value object, or a PQL Value object * @return StatementBuilder a reference to this object */ public function WithBindVariableValue($key, $value) { $this->valueMap[$key] = Pql::CreateValue($value); return $this; }
/** * @covers Pql::CreateValue */ public function testCreateValueWithNullReturnsTextValue() { $this->assertEquals(null, Pql::CreateValue(null)->value); }