From 37fa75099051a70f9aec984ae6226744aad79c8b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 28 Feb 2005 11:51:10 +0000 Subject: [PATCH] 1) corrected fix of wrong comparison with NULL in column_data_implode 2) allow for null in array in column_data_implode --- phpgwapi/inc/class.db.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/class.db.inc.php b/phpgwapi/inc/class.db.inc.php index 0ebcfa28fb..10d368be8f 100644 --- a/phpgwapi/inc/class.db.inc.php +++ b/phpgwapi/inc/class.db.inc.php @@ -1116,17 +1116,25 @@ if (is_array($data)) { + $or_null = ''; foreach($data as $k => $v) { + if (!$not_null && $use_key===True && is_null($v)) + { + $or_null = ' OR '.$this->name_quote($key).' IS NULL)'; + unset($data[$k]); + continue; + } $data[$k] = $this->quote($v,$column_type,$not_null); } - $values[] = ($use_key===True ? $key.' IN ' : '') . '('.implode(',',$data).')'; + $values[] = ($or_null?'(':'').(!count($data) ? '' : ($use_key===True ? + $this->name_quote($key).' IN ' : '') . '('.implode(',',$data).')').$or_null; } elseif (is_int($key) && $use_key===True) { $values[] = $data; } - elseif ($use_key === True && !$not_null && is_null($data)) + elseif ($glue != ',' && $use_key === True && !$not_null && is_null($data)) { $values[] = $this->name_quote($key) .' IS NULL'; }