This commit is contained in:
parent
ff1886754d
commit
647542d5ee
@ -661,4 +661,15 @@ class Doctrine_Expression extends Doctrine_Connection_Module
|
|||||||
{
|
{
|
||||||
throw new Doctrine_Expression_Exception('method not implemented');
|
throw new Doctrine_Expression_Exception('method not implemented');
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* __call
|
||||||
|
*
|
||||||
|
* for all native RDBMS functions the function name itself is returned
|
||||||
|
*/
|
||||||
|
public function __call($m, $a)
|
||||||
|
{
|
||||||
|
if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EXPR) {
|
||||||
|
throw new Doctrine_Expression_Exception('Unknown expression ' . $m);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,52 +235,50 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
|
|||||||
$pos = strpos($func, '(');
|
$pos = strpos($func, '(');
|
||||||
$name = substr($func, 0, $pos);
|
$name = substr($func, 0, $pos);
|
||||||
|
|
||||||
|
try {
|
||||||
if(method_exists($this->conn->expression, $name)) {
|
|
||||||
|
|
||||||
$argStr = substr($func, ($pos + 1), -1);
|
$argStr = substr($func, ($pos + 1), -1);
|
||||||
$args = explode(',', $argStr);
|
$args = explode(',', $argStr);
|
||||||
|
|
||||||
$func = call_user_func_array(array($this->conn->expression, $name), $args);
|
$func = call_user_func_array(array($this->conn->expression, $name), $args);
|
||||||
|
|
||||||
if(substr($func, 0, 1) !== '(') {
|
if(substr($func, 0, 1) !== '(') {
|
||||||
$pos = strpos($func, '(');
|
$pos = strpos($func, '(');
|
||||||
$name = substr($func, 0, $pos);
|
$name = substr($func, 0, $pos);
|
||||||
} else {
|
} else {
|
||||||
$name = $func;
|
$name = $func;
|
||||||
}
|
}
|
||||||
|
|
||||||
$e2 = explode(' ', $args[0]);
|
$e2 = explode(' ', $args[0]);
|
||||||
|
|
||||||
$distinct = '';
|
$distinct = '';
|
||||||
if(count($e2) > 1) {
|
if(count($e2) > 1) {
|
||||||
if(strtoupper($e2[0]) == 'DISTINCT')
|
if(strtoupper($e2[0]) == 'DISTINCT')
|
||||||
$distinct = 'DISTINCT ';
|
$distinct = 'DISTINCT ';
|
||||||
|
|
||||||
$args[0] = $e2[1];
|
$args[0] = $e2[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$parts = explode('.', $args[0]);
|
$parts = explode('.', $args[0]);
|
||||||
$owner = $parts[0];
|
$owner = $parts[0];
|
||||||
$alias = (isset($e[1])) ? $e[1] : $name;
|
$alias = (isset($e[1])) ? $e[1] : $name;
|
||||||
|
|
||||||
$e3 = explode('.', $alias);
|
$e3 = explode('.', $alias);
|
||||||
|
|
||||||
if(count($e3) > 1) {
|
if(count($e3) > 1) {
|
||||||
$alias = $e3[1];
|
$alias = $e3[1];
|
||||||
$owner = $e3[0];
|
$owner = $e3[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// a function without parameters eg. RANDOM()
|
// a function without parameters eg. RANDOM()
|
||||||
if ($owner === '') {
|
if ($owner === '') {
|
||||||
$owner = 0;
|
$owner = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pendingAggregates[$owner][] = array($name, $args, $distinct, $alias);
|
$this->pendingAggregates[$owner][] = array($name, $args, $distinct, $alias);
|
||||||
} else {
|
} catch(Doctrine_Expression_Exception $e) {
|
||||||
throw new Doctrine_Query_Exception('Unknown function '.$name);
|
throw new Doctrine_Query_Exception('Unknown function ' . $func . '.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function processPendingSubqueries()
|
public function processPendingSubqueries()
|
||||||
|
Loading…
Reference in New Issue
Block a user