function listGet($cls, $keyCol, $keyVals)
{
$pkeyMap = array_fill_keys($keyVals, array());
- $results = array_fill_keys($keyVals, array());
+ $result = array_fill_keys($keyVals, array());
$pkeyCols = self::pkeyCols($cls);
-
+
$toFetch = array();
$allPkeys = array();
$l = self::cacheGet(sprintf("%s:list-ids:%s:%s", $cls, $keyCol, $keyVal));
if ($l !== false) {
$pkeyMap[$keyVal] = $l;
- $allPkeys = array_merge($allPkeys, $l);
+ foreach ($l as $pkey) {
+ $allPkeys[] = $pkey;
+ }
} else {
$toFetch[] = $keyVal;
}
}
- $keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys);
+ if (count($allPkeys) > 0) {
+ $keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys);
- foreach ($pkeyMap as $keyVal => $pkeyList) {
- foreach ($pkeyList as $pkeyVal) {
- $i = $keyResults[$pkeyVal];
- if (!empty($i)) {
- $results[$keyVal][] = $i;
+ foreach ($pkeyMap as $keyVal => $pkeyList) {
+ foreach ($pkeyList as $pkeyVal) {
+ $i = $keyResults[implode(',',$pkeyVal)];
+ if (!empty($i)) {
+ $result[$keyVal][] = $i;
+ }
}
}
}
}
$i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
if ($i->find()) {
+ sprintf("listGet() got {$i->N} results for class $cls key $keyCol");
while ($i->fetch()) {
$copy = clone($i);
$copy->encache();
$pkeyMap[$keyVal]);
}
}
-
+
return $result;
}