Not really necessary in practice but makes better queries
This commit is contained in:
parent
8c6d0759c7
commit
e32f2b0a39
|
@ -67,10 +67,11 @@ class Memcached_DataObject extends Safe_DataObject
|
||||||
* @param string $cls Class to fetch
|
* @param string $cls Class to fetch
|
||||||
* @param string $keyCol name of column for key
|
* @param string $keyCol name of column for key
|
||||||
* @param array $keyVals key values to fetch
|
* @param array $keyVals key values to fetch
|
||||||
|
* @param boolean $skipNulls skip provided null values
|
||||||
*
|
*
|
||||||
* @return array Array of objects, in order
|
* @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;
|
$obj = new $cls;
|
||||||
|
|
||||||
|
@ -83,6 +84,14 @@ class Memcached_DataObject extends Safe_DataObject
|
||||||
throw new ServerException('Cannot do multiGet on anything but integer columns');
|
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);
|
$obj->whereAddIn($keyCol, $keyVals, $colType);
|
||||||
|
|
||||||
// Since we're inputting straight to a query: format and escape
|
// Since we're inputting straight to a query: format and escape
|
||||||
|
|
Loading…
Reference in New Issue
Block a user