1
0
mirror of https://github.com/dg/dibi.git synced 2025-09-08 21:30:46 +02:00

added Dibi\Expression [Closes #264]

This commit is contained in:
David Grudl
2017-09-21 14:51:31 +02:00
parent f0d08a990c
commit 1352437e08
3 changed files with 52 additions and 1 deletions

32
src/Dibi/Expression.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
namespace Dibi;
/**
* SQL expression.
*/
class Expression
{
use Strict;
/** @var array */
private $values;
public function __construct()
{
$this->values = func_get_args();
}
public function getValues()
{
return $this->values;
}
}

View File

@@ -458,6 +458,9 @@ final class Translator
} elseif ($value instanceof Literal) {
return (string) $value;
} elseif ($value instanceof Expression) {
return call_user_func_array([$this->connection, 'translate'], $value->getValues());
} else {
$type = is_object($value) ? get_class($value) : gettype($value);
return $this->errors[] = "**Unexpected $type**";