bit of a code cleanup
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 17cdc32..4eff400 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -427,7 +427,7 @@
 		{

 			$prefix = (count($this->ar_where) == 0) ? '' : $type;

 

-			if ( ! $this->_has_operator($k) && is_null($key[$k]))

+			if (is_null($v) && ! $this->_has_operator($k))

 			{

 				// value appears not to have been set, assign the test to IS NULL

 				$k .= ' IS NULL';

@@ -447,6 +447,9 @@
 					{

 						$k = $this->_protect_identifiers($k);

 					}

+					

+					$v = ' '.$this->escape($v);

+

 				}

 

 				if ( ! $this->_has_operator($k))

@@ -454,11 +457,6 @@
 					$k .= ' =';

 				}

 

-				if ($v !== NULL AND $escape === TRUE)

-				{

-					$v = ' '.$this->escape($v);

-				}

-

 			}

 			else

 			{

@@ -471,6 +469,7 @@
 			}

 

 			$this->ar_where[] = $prefix.$k.$v;

+			

 			if ($this->ar_caching === TRUE)

 			{

 				$this->ar_cache_where[] = $prefix.$k.$v;