Easier pkeyCols call to get primary key columns

This commit is contained in:
Mikael Nordfeldth 2015-06-04 21:51:56 +02:00
parent 20145092ce
commit ca19a5cd6d
2 changed files with 8 additions and 3 deletions

View File

@ -64,6 +64,11 @@ abstract class Managed_DataObject extends Memcached_DataObject
return parent::pkeyGetClass(get_called_class(), $kv); return parent::pkeyGetClass(get_called_class(), $kv);
} }
static function pkeyCols()
{
return parent::pkeyColsClass(get_called_class());
}
/** /**
* Get multiple items from the database by key * Get multiple items from the database by key
* *

View File

@ -34,7 +34,7 @@ class Memcached_DataObject extends Safe_DataObject
{ {
if (is_null($v)) { if (is_null($v)) {
$v = $k; $v = $k;
$keys = self::pkeyCols($cls); $keys = static::pkeyCols();
if (count($keys) > 1) { if (count($keys) > 1) {
// FIXME: maybe call pkeyGetClass() ourselves? // FIXME: maybe call pkeyGetClass() ourselves?
throw new Exception('Use pkeyGetClass() for compound primary keys'); throw new Exception('Use pkeyGetClass() for compound primary keys');
@ -246,7 +246,7 @@ class Memcached_DataObject extends Safe_DataObject
return $query; return $query;
} }
static function pkeyCols($cls) static function pkeyColsClass($cls)
{ {
$i = new $cls; $i = new $cls;
$types = $i->keyTypes(); $types = $i->keyTypes();
@ -279,7 +279,7 @@ class Memcached_DataObject extends Safe_DataObject
$pkeyMap = array_fill_keys($keyVals, array()); $pkeyMap = array_fill_keys($keyVals, array());
$result = array_fill_keys($keyVals, array()); $result = array_fill_keys($keyVals, array());
$pkeyCols = self::pkeyCols($cls); $pkeyCols = static::pkeyCols();
$toFetch = array(); $toFetch = array();
$allPkeys = array(); $allPkeys = array();