X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FMemcached_DataObject.php;h=3de7c16d9bf6d1f2c338a29604e0fd6a20c4021a;hb=b9a07330621b8c09339e33779798af46c517b7cd;hp=c1f6f644db010d9e85e4d121b73474f3cb547724;hpb=daaafd86e2dfea8e9c3e4f0c41f7cb77c926c104;p=quix0rs-gnu-social.git diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index c1f6f644db..3de7c16d9b 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -67,14 +67,15 @@ class Memcached_DataObject extends Safe_DataObject * @param string $cls Class to fetch * @param string $keyCol name of column for key * @param array $keyVals key values to fetch + * @param boolean $skipNulls skip provided null values * * @return array Array of objects, in order */ - static function multiGetClass($cls, $keyCol, array $keyVals) + static function multiGetClass($cls, $keyCol, array $keyVals, $skipNulls=true) { $obj = new $cls; - // php-compatible, for settype(), datatype + // PHP compatible datatype for settype() below $colType = $obj->columnType($keyCol); if (!in_array($colType, array('integer', 'int'))) { @@ -83,6 +84,14 @@ class Memcached_DataObject extends Safe_DataObject throw new ServerException('Cannot do multiGet on anything but integer columns'); } + if ($skipNulls) { + foreach ($keyVals as $key=>$val) { + if (is_null($val)) { + unset($keyVals[$key]); + } + } + } + $obj->whereAddIn($keyCol, $keyVals, $colType); // Since we're inputting straight to a query: format and escape