Moved multiGet into Managed_DataObject

This commit is contained in:
Mikael Nordfeldth 2013-08-29 10:38:11 +02:00
parent b3e61ce7d0
commit 79e3acf0f0
6 changed files with 17 additions and 18 deletions

View File

@ -61,6 +61,20 @@ abstract class Managed_DataObject extends Memcached_DataObject
return parent::pkeyGetClass(get_called_class(), $kv);
}
/**
* Get multiple items from the database by key
*
* @param string $keyCol name of column for key
* @param array $keyVals key values to fetch
* @param boolean $skipNulls return only non-null results?
*
* @return array Array of objects, in order
*/
static function multiGet($keyCol, array $keyVals, $skipNulls=true)
{
return parent::multiGetClass(get_called_class(), $keyCol, $keyVals, $skipNulls);
}
/**
* Get multiple items from the database by key
*

View File

@ -74,7 +74,7 @@ class Memcached_DataObject extends Safe_DataObject
*
* @return array Array of objects, in order
*/
function multiGet($cls, $keyCol, array $keyVals, $skipNulls=true)
static function multiGetClass($cls, $keyCol, array $keyVals, $skipNulls=true)
{
$result = self::pivotGetClass($cls, $keyCol, $keyVals);

View File

@ -131,11 +131,6 @@ class Notice extends Managed_DataObject
return $def;
}
function multiGet($kc, $kvs, $skipNulls=true)
{
return Memcached_DataObject::multiGet('Notice', $kc, $kvs, $skipNulls);
}
/* Notice types */
const LOCAL_PUBLIC = 1;
const REMOTE = 0;
@ -831,7 +826,7 @@ class Notice extends Managed_DataObject
$ids[] = $f2p->file_id;
}
$files = Memcached_DataObject::multiGet('File', 'id', $ids);
$files = File::multiGet('id', $ids);
$this->_attachments = $files->fetchAll();

View File

@ -79,11 +79,6 @@ class Profile extends Managed_DataObject
return $def;
}
function multiGet($keyCol, $keyVals, $skipNulls=true)
{
return parent::multiGet('Profile', $keyCol, $keyVals, $skipNulls);
}
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE

View File

@ -30,11 +30,6 @@ class User_group extends Managed_DataObject
public $join_policy; // tinyint
public $force_scope; // tinyint
function multiGet($keyCol, $keyVals, $skipNulls=true)
{
return parent::multiGet('User_group', $keyCol, $keyVals, $skipNulls);
}
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE

View File

@ -254,7 +254,7 @@ class ActivitySpamPlugin extends Plugin
foreach ($notices as $notice) {
$ids[] = $notice->id;
}
Memcached_DataObject::multiGet('Spam_score', 'notice_id', $ids);
Spam_score::multiGet('notice_id', $ids);
}
return true;
}