return parent::pkeyGetClass(get_called_class(), $kv);
}
+ /**
+ * Get a multi-instance object
+ *
+ * This is a utility method to get multiple instances with a given set of
+ * values for a specific key column. Usually used for the primary key when
+ * multiple values are desired.
+ *
+ * @param array $keyCol key column name
+ * @param array $keyVals array of key values
+ *
+ * @return get_called_class() object with multiple instances if found, or null for no hits
+ *
+ */
+ static function listGet($keyCol, $keyVals)
+ {
+ return parent::listGetClass(get_called_class(), $keyCol, $keyVals);
+ }
+
/**
* get/set an associative array of table columns
*
return $pkey;
}
- function listGet($cls, $keyCol, $keyVals)
+ static function listGetClass($cls, $keyCol, $keyVals)
{
$pkeyMap = array_fill_keys($keyVals, array());
$result = array_fill_keys($keyVals, array());
}
$i->whereAddIn($keyCol, $toFetch, $i->columnType($keyCol));
if ($i->find()) {
- sprintf("listGet() got {$i->N} results for class $cls key $keyCol");
+ sprintf(__CLASS__ . "() got {$i->N} results for class $cls key $keyCol");
while ($i->fetch()) {
$copy = clone($i);
$copy->encache();
return $this->_attachments;
}
- $f2ps = Memcached_DataObject::listGet('File_to_post', 'post_id', array($this->id));
+ $f2ps = File_to_post::listGet('post_id', array($this->id));
$ids = array();
return $this->_replies;
}
- $replyMap = Memcached_DataObject::listGet('Reply', 'notice_id', array($this->id));
+ $replyMap = Reply::listGet('notice_id', array($this->id));
$ids = array();
return $this->_groups;
}
- $gis = Memcached_DataObject::listGet('Group_inbox', 'notice_id', array($this->id));
+ $gis = Group_inbox::listGet('notice_id', array($this->id));
$ids = array();
{
$ids = self::_idsOf($notices);
- $gis = Memcached_DataObject::listGet('Group_inbox', 'notice_id', $ids);
+ $gis = Group_inbox::listGet('notice_id', $ids);
$gids = array();
{
$ids = self::_idsOf($notices);
- $f2pMap = Memcached_DataObject::listGet('File_to_post', 'post_id', $ids);
+ $f2pMap = File_to_post::listGet('post_id', $ids);
$fileIds = array();
if (isset($this->_faves) && is_array($this->_faves)) {
return $this->_faves;
}
- $faveMap = Memcached_DataObject::listGet('Fave', 'notice_id', array($this->id));
+ $faveMap = Fave::listGet('notice_id', array($this->id));
$this->_faves = $faveMap[$this->id];
return $this->_faves;
}
static function fillFaves(&$notices)
{
$ids = self::_idsOf($notices);
- $faveMap = Memcached_DataObject::listGet('Fave', 'notice_id', $ids);
+ $faveMap = Fave::listGet('notice_id', $ids);
$cnt = 0;
$faved = array();
foreach ($faveMap as $id => $faves) {
static function fillReplies(&$notices)
{
$ids = self::_idsOf($notices);
- $replyMap = Memcached_DataObject::listGet('Reply', 'notice_id', $ids);
+ $replyMap = Reply::listGet('notice_id', $ids);
foreach ($notices as $notice) {
$replies = $replyMap[$notice->id];
$ids = array();
if (isset($this->_repeats) && is_array($this->_repeats)) {
return $this->_repeats;
}
- $repeatMap = Memcached_DataObject::listGet('Notice', 'repeat_of', array($this->id));
+ $repeatMap = Notice::listGet('repeat_of', array($this->id));
$this->_repeats = $repeatMap[$this->id];
return $this->_repeats;
}
static function fillRepeats(&$notices)
{
$ids = self::_idsOf($notices);
- $repeatMap = Memcached_DataObject::listGet('Notice', 'repeat_of', $ids);
+ $repeatMap = Notice::listGet('repeat_of', $ids);
foreach ($notices as $notice) {
$repeats = $repeatMap[$notice->id];
$notice->_setRepeats($repeats);
function getMessagesTo()
{
- $msgMap = Memcached_DataObject::listGet('Message', 'to_profile', array($this->user->id));
+ $msgMap = Message::listGet('to_profile', array($this->user->id));
$messages = $msgMap[$this->user->id];
function getMessagesFrom()
{
- $msgMap = Memcached_DataObject::listGet('Message', 'from_profile', array($this->user->id));
+ $msgMap = Message::listGet('from_profile', array($this->user->id));
$messages = $msgMap[$this->user->id];