Permalink
Browse files

Fixing DboSource::group() to test for virtual fields when first param…

…eter is not an array
  • Loading branch information...
1 parent cecfd72 commit 3fe4b4661479e8090d4cf27f9feb12b276e8578a @lorenzo lorenzo committed Jan 11, 2010
Showing with 8 additions and 6 deletions.
  1. +8 −6 cake/libs/model/datasources/dbo_source.php
@@ -2330,14 +2330,16 @@ function order($keys, $direction = 'ASC', $model = null) {
*/
function group($group, $model = null) {
if ($group) {
- if (is_array($group)) {
- foreach($group as $index => $key) {
- if ($model->isVirtualField($key)) {
- $group[$index] = '(' . $model->getVirtualField($key) . ')';
- }
+ if (!is_array($group)) {
+ $group = array($group);
+ }
+
+ foreach($group as $index => $key) {
+ if ($model->isVirtualField($key)) {
+ $group[$index] = '(' . $model->getVirtualField($key) . ')';
}
- $group = implode(', ', $group);
}
+ $group = implode(', ', $group);
return ' GROUP BY ' . $this->__quoteFields($group);
}
return null;

0 comments on commit 3fe4b46

Please sign in to comment.