Changed the behaviour of variables submitted to the where() clause with no values to auto set "IS NULL"
Added parenthesis around table names in SQL FROM
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 0a4327b..dfa0a3e 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -226,16 +226,25 @@
  	 	

 		foreach ($key as $k => $v)

 		{

+

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

+

+			if (is_null($key[$k]))

+			{

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

+				$k .= ' IS NULL';

+			}

 			

 			if ( ! is_null($v))

 			{

+			

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

 				{

 					$k .= ' =';

 				}

-			

+

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

+

 			}

 						

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

@@ -278,7 +287,7 @@
 	 */

 	function or_where_in($key = NULL, $values = NULL)

 	{	 	

-		return $this->_where_in($key, $values, FALSE, 'or');

+		return $this->_where_in($key, $values, FALSE, 'OR ');

 	}

 

 	// --------------------------------------------------------------------

@@ -316,7 +325,7 @@
 	 */

 	function or_where_not_in($key = NULL, $values = NULL)

 	{	 	

-		return $this->_where_in($key, $values, FALSE, 'or');

+		return $this->_where_in($key, $values, FALSE, 'OR ');

 	}

 

 	// --------------------------------------------------------------------

@@ -333,7 +342,7 @@
 	 * @param	string	

 	 * @return	object

 	 */

-	function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'and')

+	function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ')

 	{	 	

 		if ($key === NULL || !is_array($values))

 		{

@@ -341,7 +350,6 @@
 		}

 

 		$not = ($not) ? ' NOT ' : '';

-		$type = (strtolower($type) == 'or') ? ' OR ' : ' AND ';

 

 		foreach ($values as $value)

 		{

@@ -955,13 +963,13 @@
 			}

 			return FALSE;

 		}		

-		

+	

 		$sql = $this->_delete($this->dbprefix.$table, $this->ar_where, $this->ar_limit);

 

 		$this->_reset_write();

 		return $this->query($sql);

 	}

-	

+

 	// --------------------------------------------------------------------

 

 	/**

@@ -1020,7 +1028,7 @@
 		if (count($this->ar_from) > 0)

 		{

 			$sql .= "\nFROM ";

-			$sql .= implode(', ', $this->ar_from);

+			$sql .= '(' . implode(', ', $this->ar_from) . ')';

 		}

 

 		if (count($this->ar_join) > 0)