From 898049a4012eaecd99e7a418726215e656677809 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 14 Jan 2007 01:53:51 +0000 Subject: fixed order by without condition --- framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php') diff --git a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php index 35452849..ffb2fc31 100644 --- a/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php +++ b/framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php @@ -34,25 +34,24 @@ class TPgsqlMetaData extends TDbMetaDataCommon { $sql = ''; if(($condition = $criteria->getCondition())!==null) - $sql .= $condition; + $sql .= ' WHERE '.$condition; $orders=array(); foreach($criteria->getOrdersBy() as $by=>$ordering) - $orders[] = $conn->quoteString($by).' '.$this->getOrdering($ordering); + $orders[] = $this->getOrdering($by, $ordering); if(count($orders) > 0) $sql .= ' ORDER BY '.implode(', ', $orders); if(($limit = $criteria->getLimit())!==null) $sql .= ' LIMIT '.intval($limit); //assumes integer limit? if(($offset = $criteria->getOffset())!==null) $sql .= ' OFFSET '.intval($offset); //assumes integer offset? - return strlen($sql) > 0 ? ' WHERE '.$sql : ''; + return strlen($sql) > 0 ? $sql : ''; } - private function getOrdering($direction) + protected function getOrdering($by, $direction) { - if(strtolower($direction) == 'desc') - return 'DESC'; - else - return 'ASC'; + $dir = strtolower($direction) == 'desc' ? 'DESC' : 'ASC'; + return $this->getColumn($by)->getName(). ' '.$dir; } + } ?> \ No newline at end of file -- cgit v1.2.3