Permalink
Browse files

Working array postHydration messed up distinct and function on userap…

…i.getall
  • Loading branch information...
matheo committed Mar 28, 2012
1 parent 2db5472 commit 09d7168e3c1a2aa8ae9fbc09abee38e2cf650de2
Showing with 17 additions and 4 deletions.
  1. +17 −4 src/modules/Clip/lib/Clip/Api/User.php
@@ -245,15 +245,19 @@ public function getall($args)
if ($args['function']) {
$publist = $query->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);
- if (count($publist) == 1) {
- $publist = reset($publist);
+ // remove the posthydrated core values
+ foreach ($publist as $k => $v) {
+ if (strpos($k, 'core_') === 0) {
+ unset($publist[$k]);
+ }
}
+ $publist = (count($publist) == 1) ? reset($publist) : $publist;
+
} else {
//// Count
if ($args['countmode'] != 'no') {
$pubcount = $query->count();
-
}
//// Collection
@@ -282,9 +286,18 @@ public function getall($args)
//// execution and postprocess
if ($args['distinct']) {
- // distinct field
+ // distinct field(s)
$publist = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
+ // remove the posthydrated core values
+ foreach ($publist as $j => $res) {
+ foreach ($res as $k => $v) {
+ if (strpos($k, 'core_') === 0) {
+ unset($publist[$j][$k]);
+ }
+ }
+ }
+
if (strpos($args['distinct'], ',') === false) {
foreach ($publist as $k => $v) {
$publist[$k] = $v[$args['distinct']];

0 comments on commit 09d7168

Please sign in to comment.