From 293a6c38f22edb630798aed9a2b771372f1c7f8d Mon Sep 17 00:00:00 2001 From: Joshua Paine Date: Thu, 23 Apr 2009 01:26:24 +0800 Subject: [PATCH] keep Recess from prepending table name to order by clause when doing something like $model->all()->orderBy('rand()') Right now only works right for functions with no column name arguments, which is probably only rand(). Full implementation would parse out column names in function args and handle prepending on them. But it might be ok to let people do their own darn prepending in that case. Signed-off-by: Kris Jordan (cherry picked from commit f326e62eafbb2fc44b4060954e0b3aedb3fc827b) --- recess/recess/database/sql/SqlBuilder.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recess/recess/database/sql/SqlBuilder.class.php b/recess/recess/database/sql/SqlBuilder.class.php index dacab9d..774a8e4 100644 --- a/recess/recess/database/sql/SqlBuilder.class.php +++ b/recess/recess/database/sql/SqlBuilder.class.php @@ -443,7 +443,7 @@ public function orderBy($clause) { $name = $clause; } - if(isset($this->table) && strpos($clause,'.') === false && !array_key_exists($name, $this->selectAs)) { + if(isset($this->table) && strpos($clause,'.') === false && strpos($name,'(') === false && !array_key_exists($name, $this->selectAs)) { $this->orderBy[] = $this->tableAsPrefix() . '.' . $clause; } else { $this->orderBy[] = $clause;