*
* @return array Array of objects, in order
*/
- function multiGet($cls, $keyCol, $keyVals, $skipNulls=true)
+ static function multiGetClass($cls, $keyCol, array $keyVals, $skipNulls=true)
{
$result = self::pivotGetClass($cls, $keyCol, $keyVals);
return $pkey;
}
- static function listGetClass($cls, $keyCol, $keyVals)
+ static function listFindClass($cls, $keyCol, array $keyVals)
+ {
+ if (!is_a($cls, __CLASS__, true)) {
+ throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class');
+ }
+
+ $i = new $cls;
+ $i->whereAddIn($keyCol, $keyVals, $i->columnType($keyCol));
+ if (!$i->find()) {
+ throw new NoResultException($i);
+ }
+
+ sprintf(__CLASS__ . "() got {$i->N} results for class $cls key $keyCol");
+ return $i;
+ }
+
+ static function listGetClass($cls, $keyCol, array $keyVals)
{
if (!is_a($cls, __CLASS__, true)) {
throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class');
}
if (count($toFetch) > 0) {
- $i = new $cls;
- $i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
- if ($i->find()) {
- sprintf(__CLASS__ . "() got {$i->N} results for class $cls key $keyCol");
+ try {
+ $i = self::listFindClass($cls, $keyCol, $toFetch);
+
while ($i->fetch()) {
$copy = clone($i);
$copy->encache();
}
$pkeyMap[$i->$keyCol][] = $pkeyVal;
}
+ } catch (NoResultException $e) {
+ // no results foudn for our keyVals, so we leave them as empty arrays
}
foreach ($toFetch as $keyVal) {
self::cacheSet(sprintf("%s:list-ids:%s:%s", strtolower($cls), $keyCol, $keyVal),
/**
* @todo FIXME: Should this return false on lookup fail to match getKV?
*/
- static function pkeyGetClass($cls, $kv)
+ static function pkeyGetClass($cls, array $kv)
{
if (!is_a($cls, __CLASS__, true)) {
throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class');