diff options
author | wei <> | 2007-01-14 01:53:51 +0000 |
---|---|---|
committer | wei <> | 2007-01-14 01:53:51 +0000 |
commit | 898049a4012eaecd99e7a418726215e656677809 (patch) | |
tree | fd5902bb1c8a342657fcc2dc83ebe8917603825a /framework/Data/ActiveRecord/Vendor | |
parent | b2f63869d92ffc5ca1078ae5854e8de4f07a6927 (diff) |
fixed order by without condition
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor')
-rw-r--r-- | framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php | 15 | ||||
-rw-r--r-- | framework/Data/ActiveRecord/Vendor/TPgsqlMetaData.php | 15 | ||||
-rw-r--r-- | framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php | 14 |
3 files changed, 19 insertions, 25 deletions
diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php b/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php index 0ac3798d..b0b2ef87 100644 --- a/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php +++ b/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php @@ -32,10 +32,10 @@ class TMysqlMetaData 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)
@@ -44,16 +44,13 @@ class TMysqlMetaData extends TDbMetaDataCommon $offset = $offset===null?0:intval($offset); //assumes integer offset
$sql .= ' LIMIT '.$offset.', '.intval($limit); //assumes integer limit
}
- 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 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 diff --git a/framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php b/framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php index 22d1759b..129a0acf 100644 --- a/framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php +++ b/framework/Data/ActiveRecord/Vendor/TSqliteMetaData.php @@ -32,10 +32,10 @@ class TSqliteMetaData 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)
@@ -44,15 +44,13 @@ class TSqliteMetaData extends TDbMetaDataCommon $offset = $offset===null?0:intval($offset); //assume integer offset?
$sql .= ' LIMIT '.$offset.', '.intval($limit); //assume integer limit?
}
- 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;
}
/**
|