Not really necessary in practice but makes better queries

This commit is contained in:
Mikael Nordfeldth 2016-03-23 17:51:13 +01:00
parent 8c6d0759c7
commit e32f2b0a39
1 changed files with 10 additions and 1 deletions

View File

@ -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