From 4c0772f2ce11d86f4663b5ffb0a6c661018abedd Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Tue, 15 Oct 2013 21:12:50 +0300 Subject: [PATCH] Do not handle empty collections --- lib/db.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/db.php b/lib/db.php index 823b76c8..c1a799c4 100644 --- a/lib/db.php +++ b/lib/db.php @@ -98,7 +98,10 @@ abstract class Db { if (!is_array($value)){ $value = array($value); } - if (count($value)===1){ + $count = count($value); + if ($count===0){ + return 0; + } elseif ($count===1){ $result = $this->execute('DELETE FROM ' . $this->tableName . ' WHERE `'. $field .'` =?', $value); } else { $stmt = $this->buildInQuery($field, $value); @@ -129,7 +132,10 @@ abstract class Db { if (!is_array($value)){ $value = array($value); } - if (count($value)===1){ + $count = count($value); + if ($count===0){ + return array(); + } elseif ($count===1){ $result = $this->execute('SELECT * FROM ' . $this->tableName . ' WHERE `'. $field .'` =?', $value); } else { $stmt = $this->buildInQuery($field, $value);