From: Mikael Nordfeldth Date: Wed, 23 Mar 2016 16:51:13 +0000 (+0100) Subject: Not really necessary in practice but makes better queries X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e32f2b0a39042556d84dd3b12bff2dd226d8cfd2;p=quix0rs-gnu-social.git Not really necessary in practice but makes better queries --- diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 41ce715210..3de7c16d9b 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -67,10 +67,11 @@ 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; @@ -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