- $i = DB_DataObject::factory($cls);
- if (empty($i)) {
- throw new Exception(_('Cannot instantiate class ' . $cls));
- }
- $i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
- if ($i->find()) {
- while ($i->fetch()) {
- $copy = clone($i);
- $copy->encache();
- $result[$i->$keyCol][] = $copy;
- }
- }
- foreach ($toFetch as $keyVal)
- {
- self::cacheSet(sprintf("%s:list:%s:%s", $cls, $keyCol, $keyVal),
- $result[$keyVal]);
- }
- }
-
- return $result;
- }
-
- function columnType($columnName)
- {
- $keys = $this->table();
- if (!array_key_exists($columnName, $keys)) {
- throw new Exception('Unknown key column ' . $columnName . ' in ' . join(',', array_keys($keys)));
- }
-
- $def = $keys[$columnName];
-
- if ($def & DB_DATAOBJECT_INT) {
- return 'integer';
- } else {
- return 'string';
- }
- }
-
+ $i = DB_DataObject::factory($cls);
+ if (empty($i)) {
+ // TRANS: Exception thrown when a class (%s) could not be instantiated.
+ throw new Exception(sprintf(_('Cannot instantiate class %s.'),$cls));
+ }
+ $i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
+ if ($i->find()) {
+ while ($i->fetch()) {
+ $copy = clone($i);
+ $copy->encache();
+ $result[$i->$keyCol][] = $copy;
+ }
+ }
+ foreach ($toFetch as $keyVal)
+ {
+ self::cacheSet(sprintf("%s:list:%s:%s", $cls, $keyCol, $keyVal),
+ $result[$keyVal]);
+ }
+ }
+
+ return $result;
+ }
+
+ function columnType($columnName)
+ {
+ $keys = $this->table();
+ if (!array_key_exists($columnName, $keys)) {
+ throw new Exception('Unknown key column ' . $columnName . ' in ' . join(',', array_keys($keys)));
+ }
+
+ $def = $keys[$columnName];
+
+ if ($def & DB_DATAOBJECT_INT) {
+ return 'integer';
+ } else {
+ return 'string';
+ }
+ }
+