<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -64,10 +64,8 @@
 			$options[&quot;from&quot;] = (array) $options[&quot;from&quot;];
 			$options[&quot;select&quot;] = (array) $options[&quot;select&quot;];
 
-			if (is_numeric($id)) {
-				$options[&quot;where&quot;][] = &quot;id = :id&quot;;
-				$options[&quot;params&quot;][&quot;:id&quot;] = $id;
-			}
+			if (is_numeric($id))
+				$options[&quot;where&quot;][&quot;id&quot;] = $id;
 
 			$trigger = Trigger::current();
 			$trigger-&gt;filter($options, $model_name.&quot;_grab&quot;);</diff>
      <filename>includes/class/Model.php</filename>
    </modified>
    <modified>
      <diff>@@ -56,7 +56,7 @@
 					break;
 				case &quot;mysqli&quot;:
 					foreach ($params as $name =&gt; $val)
-						$query = preg_replace(&quot;/{$name}([^a-zA-Z0-9_]|$)/&quot;, &quot;'&quot;.$this-&gt;escape($val).&quot;'\\1&quot;, $query);
+						$query = preg_replace(&quot;/{$name}([^a-zA-Z0-9_]|$)/&quot;, SQL::current()-&gt;escape($val).&quot;\\1&quot;, $query);
 
 					try {
 						if (!$this-&gt;query = $this-&gt;db-&gt;query($query))
@@ -67,7 +67,7 @@
 					break;
 				case &quot;mysql&quot;:
 					foreach ($params as $name =&gt; $val)
-						$query = preg_replace(&quot;/{$name}([^a-zA-Z0-9_]|$)/&quot;, &quot;'&quot;.$this-&gt;escape($val).&quot;'\\1&quot;, $query);
+						$query = preg_replace(&quot;/{$name}([^a-zA-Z0-9_]|$)/&quot;, SQL::current()-&gt;escape($val).&quot;\\1&quot;, $query);
 
 					try {
 						if (!$this-&gt;query = @mysql_query($query))
@@ -156,30 +156,6 @@
 		}
 
 		/**
-		 * Function: escape
-		 * Escapes a string, escaping things like $1 and C:\foo\bar so that they don't get borked by the preg_replace.
-		 * This also handles calling the SQL connection method's &quot;escape_string&quot; functions.
-		 */
-		public function escape($string) {
-			switch(SQL::current()-&gt;method()) {
-				case &quot;pdo&quot;:
-					$string = $this-&gt;db-&gt;quote($string);
-					break;
-				case &quot;mysqli&quot;:
-					$string = $this-&gt;db-&gt;escape_string($string);
-					break;
-				case &quot;mysql&quot;:
-					$string = mysql_real_escape_string($string);
-					break;
-			}
-
-			$string = str_replace('\\', '\\\\', $string);
-			$string = str_replace('$', '\$', $string);
-
-			return $string;
-		}
-
-		/**
 		 * Function: handle
 		 * Handles exceptions thrown by failed queries.
 		 */</diff>
      <filename>includes/class/Query.php</filename>
    </modified>
    <modified>
      <diff>@@ -68,11 +68,11 @@
 		 * Function: build_update
 		 * Creates a full update query.
 		 */
-		public static function build_update($table, $conds, $data) {
+		public static function build_update($table, $conds, $data, &amp;$params = array()) {
 			return &quot;
 				UPDATE __$table
 				SET &quot;.self::build_update_values($data).&quot;
-				&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $table) : &quot;&quot;).&quot;
+				&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $table, $params) : &quot;&quot;).&quot;
 			&quot;;
 		}
 
@@ -80,10 +80,10 @@
 		 * Function: build_delete
 		 * Creates a full delete query.
 		 */
-		public static function build_delete($table, $conds) {
+		public static function build_delete($table, $conds, &amp;$params = array()) {
 			return &quot;
 				DELETE FROM __$table
-				&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $table) : &quot;&quot;).&quot;
+				&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $table, $params) : &quot;&quot;).&quot;
 			&quot;;
 		}
 
@@ -118,11 +118,11 @@
 		 * Function: build_count
 		 * Creates a SELECT COUNT(1) query.
 		 */
-		public static function build_count($tables, $conds) {
+		public static function build_count($tables, $conds, &amp;$params = array()) {
 			$query = &quot;
 				SELECT COUNT(1) AS count
 				FROM &quot;.self::build_from($tables);
-			$query.= &quot;\n\t\t\t\t&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $tables) : &quot;&quot;);
+			$query.= &quot;\n\t\t\t\t&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $tables, $params) : &quot;&quot;);
 			return $query;
 		}
 
@@ -146,12 +146,11 @@
 		 * Function: build_where
 		 * Creates a WHERE query.
 		 */
-		public static function build_where($conds, $tables = null) {
-			$conditions = (array) $conds;
+		public static function build_where($conds, $tables = null, &amp;$params = array()) {
+			$conds = (array) $conds;
 			$tables = (array) $tables;
 
-			foreach ($conditions as &amp;$condition)
-				self::tablefy($condition, $tables);
+			$conditions = self::build_conditions($conds, $params, $tables);
 
 			return implode(&quot; AND &quot;, array_filter($conditions));
 		}
@@ -186,19 +185,68 @@
 			return implode(&quot;, &quot;, $order);
 		}
 
+		public static function build_conditions($conds, &amp;$params, $tables) {
+			foreach ($conds as $key =&gt; $val) {
+				if (is_numeric($key)) # Full expression
+					$cond = $val;
+				else { # Key =&gt; Val expression
+					if (substr($key, -4) == &quot; not&quot;) { # Negation
+						$key = substr($key, 0, -4);
+						if (is_array($val))
+							$cond = $key.&quot; NOT IN &quot;.self::build_in($val);
+						elseif ($val === null)
+							$cond = $key.&quot; IS NOT NULL&quot;;
+						else {
+							$cond = $key.&quot; != :&quot;.$key;
+							$params[&quot;:&quot;.$key] = $val;
+						}
+					} elseif (substr($key, -5) == &quot; like&quot;) { # LIKE
+						$key = substr($key, 0, -5);
+						$cond = $key.&quot; LIKE :&quot;.$key;
+						$params[&quot;:&quot;.$key] = $val;
+					} elseif (substr($key, -9) == &quot; not like&quot;) { # NOT LIKE
+						$key = substr($key, 0, -9);
+						$cond = $key.&quot; NOT LIKE :&quot;.$key;
+						$params[&quot;:&quot;.$key] = $val;
+					} else { # Equation
+						if (is_array($val))
+							$cond = $key.&quot; IN &quot;.self::build_in($val);
+						elseif ($val === null)
+							$cond = $key.&quot; IS NULL&quot;;
+						else {
+							$cond = $key.&quot; = :&quot;.$key;
+							$params[&quot;:&quot;.$key] = $val;
+						}
+					}
+				}
+
+				self::tablefy($cond, $tables);
+				$conditions[] = $cond;
+			}
+
+			return $conditions;
+		}
+
+		public static function build_in($vals) {
+			$return = array();
+			foreach ($vals as $val)
+				$return[] = SQL::current()-&gt;escape($val);
+			return &quot;(&quot;.join(&quot;,&quot;, $return).&quot;)&quot;;
+		}
+
 		/**
 		 * Function: build_select
 		 * Creates a full SELECT query.
 		 */
-		public static function build_select($tables, $fields, $conds, $order = null, $limit = null, $offset = null, $group = null, $left_join = null) {
+		public static function build_select($tables, $fields, $conds, $order = null, $limit = null, $offset = null, $group = null, $left_join = null, &amp;$params = array()) {
 			$query = &quot;
 				SELECT &quot;.self::build_select_header($fields, $tables).&quot;
 				FROM &quot;.self::build_from($tables);
 			if (isset($left_join))
 				foreach ($left_join as $join)
-					$query.= &quot;\n\t\t\t\tLEFT JOIN __&quot;.$join[&quot;table&quot;].&quot; ON &quot;.self::build_where($join[&quot;where&quot;], $join[&quot;table&quot;]);
+					$query.= &quot;\n\t\t\t\tLEFT JOIN __&quot;.$join[&quot;table&quot;].&quot; ON &quot;.self::build_where($join[&quot;where&quot;], $join[&quot;table&quot;], $params);
 			$query.= &quot;
-				&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $tables) : &quot;&quot;).&quot;
+				&quot;.($conds ? &quot;WHERE &quot;.self::build_where($conds, $tables, $params) : &quot;&quot;).&quot;
 				&quot;.($group ? &quot;GROUP BY &quot;.self::build_group($group, $tables) : &quot;&quot;).&quot;
 				&quot;.($order ? &quot;ORDER BY &quot;.self::build_order($order, $tables) : &quot;&quot;).&quot;
 				&quot;.self::build_limits($offset, $limit).&quot;</diff>
      <filename>includes/class/QueryBuilder.php</filename>
    </modified>
    <modified>
      <diff>@@ -194,7 +194,7 @@
 		 *     $params - An associative array of parameters used in the query.
 		 */
 		public function count($tables, $conds = null, $params = array(), $throw_exceptions = false) {
-			return $this-&gt;query(QueryBuilder::build_count($tables, $conds), $params, $throw_exceptions)-&gt;fetchColumn();
+			return $this-&gt;query(QueryBuilder::build_count($tables, $conds, $params), $params, $throw_exceptions)-&gt;fetchColumn();
 		}
 
 		/**
@@ -213,7 +213,7 @@
 		 *     $left_join - An array of additional LEFT JOINs.
 		 */
 		public function select($tables, $fields = &quot;*&quot;, $conds = null, $order = null, $params = array(), $limit = null, $offset = null, $group = null, $left_join = null, $throw_exceptions = false) {
-			return $this-&gt;query(QueryBuilder::build_select($tables, $fields, $conds, $order, $limit, $offset, $group, $left_join), $params, $throw_exceptions);
+			return $this-&gt;query(QueryBuilder::build_select($tables, $fields, $conds, $order, $limit, $offset, $group, $left_join, $params), $params, $throw_exceptions);
 		}
 
 		/**
@@ -253,7 +253,7 @@
 		 *     $params - An associative array of parameters used in the query.
 		 */
 		public function update($table, $conds, $data, $params = array(), $throw_exceptions = false) {
-			return $this-&gt;query(QueryBuilder::build_update($table, $conds, $data), $params, $throw_exceptions);
+			return $this-&gt;query(QueryBuilder::build_update($table, $conds, $data, $params), $params, $throw_exceptions);
 		}
 
 		/**
@@ -266,7 +266,7 @@
 		 *     $params - An associative array of parameters used in the query.
 		 */
 		public function delete($table, $conds, $params = array(), $throw_exceptions = false) {
-			return $this-&gt;query(QueryBuilder::build_delete($table, $conds), $params, $throw_exceptions);
+			return $this-&gt;query(QueryBuilder::build_delete($table, $conds, $params), $params, $throw_exceptions);
 		}
 
 		/**
@@ -288,12 +288,27 @@
 		}
 
 		/**
-		 * Function: current
-		 * Returns a singleton reference to the current connection.
+		 * Function: escape
+		 * Escapes a string, escaping things like $1 and C:\foo\bar so that they don't get borked by the preg_replace.
+		 * This also handles calling the SQL connection method's &quot;escape_string&quot; functions.
 		 */
-		public static function &amp; current() {
-			static $instance = null;
-			return $instance = (empty($instance)) ? new self() : $instance ;
+		public function escape($string) {
+			switch(SQL::current()-&gt;method()) {
+				case &quot;pdo&quot;:
+					$string = $this-&gt;db-&gt;quote($string);
+					break;
+				case &quot;mysqli&quot;:
+					$string = &quot;'&quot;.$this-&gt;db-&gt;escape_string($string).&quot;'&quot;;
+					break;
+				case &quot;mysql&quot;:
+					$string = &quot;'&quot;.mysql_real_escape_string($string).&quot;'&quot;;
+					break;
+			}
+
+			$string = str_replace('\\', '\\\\', $string);
+			$string = str_replace('$', '\$', $string);
+
+			return $string;
 		}
 
 		/**
@@ -343,6 +358,15 @@
 		public function second_from_datetime($datetime) {
 			return when(&quot;s&quot;, $datetime);
 		}
+
+		/**
+		 * Function: current
+		 * Returns a singleton reference to the current connection.
+		 */
+		public static function &amp; current() {
+			static $instance = null;
+			return $instance = (empty($instance)) ? new self() : $instance ;
+		}
 	}
 
 	$sql = SQL::current();</diff>
      <filename>includes/class/SQL.php</filename>
    </modified>
    <modified>
      <diff>@@ -183,16 +183,12 @@
 			fallback($_GET['query'], &quot;&quot;);
 			list($where, $params) = keywords(urldecode($_GET['query']), &quot;xml LIKE :query&quot;);
 
-			if (!empty($_GET['month'])) {
-				$where[] = &quot;created_at LIKE :when&quot;;
-				$params[&quot;:when&quot;] = $_GET['month'].&quot;-%&quot;;
-			}
+			if (!empty($_GET['month']))
+				$where[&quot;created_at like&quot;] = $_GET['month'].&quot;-%&quot;;
 
 			$visitor = Visitor::current();
-			if (!$visitor-&gt;group()-&gt;can(&quot;view_draft&quot;, &quot;edit_draft&quot;, &quot;edit_post&quot;, &quot;delete_draft&quot;, &quot;delete_post&quot;)) {
-				$where[] = &quot;user_id = :visitor_id&quot;;
-				$params[':visitor_id'] = $visitor-&gt;id;
-			}
+			if (!$visitor-&gt;group()-&gt;can(&quot;view_draft&quot;, &quot;edit_draft&quot;, &quot;edit_post&quot;, &quot;delete_draft&quot;, &quot;delete_post&quot;))
+				$where[&quot;user_id&quot;] = $visitor-&gt;id;
 
 			$this-&gt;context[&quot;posts&quot;] = new Paginator(Post::find(array(&quot;placeholders&quot; =&gt; true,
 			                                                         &quot;drafts&quot; =&gt; true,
@@ -243,7 +239,7 @@
 				error(__(&quot;No ID Specified&quot;), __(&quot;An ID is required to edit a page.&quot;));
 
 			$this-&gt;context[&quot;page&quot;] = new Page($_GET['id'], array(&quot;filter&quot; =&gt; false));
-			$this-&gt;context[&quot;pages&quot;] = Page::find(array(&quot;where&quot; =&gt; &quot;id != :id&quot;, &quot;params&quot; =&gt; array(&quot;:id&quot; =&gt; $_GET['id'])));
+			$this-&gt;context[&quot;pages&quot;] = Page::find(array(&quot;where&quot; =&gt; array(&quot;id not&quot; =&gt; $_GET['id'])));
 		}
 
 		/**
@@ -335,7 +331,9 @@
 			fallback($_GET['query'], &quot;&quot;);
 			list($where, $params) = keywords(urldecode($_GET['query']), &quot;(title LIKE :query OR body LIKE :query)&quot;);
 
-			$this-&gt;context[&quot;pages&quot;] = new Paginator(Page::find(array(&quot;placeholders&quot; =&gt; true, &quot;where&quot; =&gt; $where, &quot;params&quot; =&gt; $params)), 25);
+			$this-&gt;context[&quot;pages&quot;] = new Paginator(Page::find(array(&quot;placeholders&quot; =&gt; true,
+			                                                         &quot;where&quot; =&gt; $where,
+			                                                         &quot;params&quot; =&gt; $params)), 25);
 		}
 
 		/**
@@ -349,8 +347,8 @@
 			$config = Config::current();
 
 			$this-&gt;context[&quot;default_group&quot;] = new Group($config-&gt;default_group);
-			$this-&gt;context[&quot;groups&quot;] = Group::find(array(&quot;where&quot; =&gt; array(&quot;id != :guest_id&quot;, &quot;id != :default_id&quot;),
-			                                             &quot;params&quot; =&gt; array(&quot;:guest_id&quot; =&gt; $config-&gt;guest_group, &quot;:default_id&quot; =&gt; $config-&gt;default_group),
+			$this-&gt;context[&quot;groups&quot;] = Group::find(array(&quot;where&quot; =&gt; array(&quot;id not&quot; =&gt; array($config-&gt;guest_group,
+			                                                                                $config-&gt;default_group)),
 			                                             &quot;order&quot; =&gt; &quot;id DESC&quot;));
 		}
 
@@ -368,8 +366,7 @@
 			if (empty($_POST['login']))
 				error(__(&quot;Error&quot;), __(&quot;Please enter a username for your account.&quot;));
 
-			$check = new User(null, array(&quot;where&quot; =&gt; &quot;login = :login&quot;,
-			                              &quot;params&quot; =&gt; array(&quot;:login&quot; =&gt; $_POST['login'])));
+			$check = new User(null, array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $_POST['login'])));
 			if (!$check-&gt;no_results)
 				error(__(&quot;Error&quot;), __(&quot;That username is already in use.&quot;));
 
@@ -400,8 +397,7 @@
 
 			$this-&gt;context[&quot;user&quot;] = new User($_GET['id']);
 			$this-&gt;context[&quot;groups&quot;] = Group::find(array(&quot;order&quot; =&gt; &quot;id ASC&quot;,
-			                                             &quot;where&quot; =&gt; &quot;id != :guest_id&quot;,
-			                                             &quot;params&quot; =&gt; array(&quot;:guest_id&quot; =&gt; Config::current()-&gt;guest_group)));
+			                                             &quot;where&quot; =&gt; array(&quot;id not&quot; =&gt; Config::current()-&gt;guest_group)));
 		}
 
 		/**
@@ -446,8 +442,7 @@
 				show_403(__(&quot;Access Denied&quot;), __(&quot;You do not have sufficient privileges to delete users.&quot;));
 
 			$this-&gt;context[&quot;user&quot;] = new User($_GET['id']);
-			$this-&gt;context[&quot;users&quot;] = User::find(array(&quot;where&quot; =&gt; &quot;id != :deleting_id&quot;,
-			                                           &quot;params&quot; =&gt; array(&quot;:deleting_id&quot; =&gt; $_GET['id'])));
+			$this-&gt;context[&quot;users&quot;] = User::find(array(&quot;where&quot; =&gt; array(&quot;id not&quot; =&gt; $_GET['id'])));
 		}
 
 		/**
@@ -585,9 +580,8 @@
 				show_403(__(&quot;Access Denied&quot;), __(&quot;You do not have sufficient privileges to delete groups.&quot;));
 
 			$this-&gt;context[&quot;group&quot;] = new Group($_GET['id']);
-			$this-&gt;context[&quot;groups&quot;] = Group::find(array(&quot;where&quot; =&gt; &quot;id != :group_id&quot;,
-			                                             &quot;order&quot; =&gt; &quot;id ASC&quot;,
-			                                             &quot;params&quot; =&gt; array(&quot;:group_id&quot; =&gt; $_GET['id'])));
+			$this-&gt;context[&quot;groups&quot;] = Group::find(array(&quot;where&quot; =&gt; array(&quot;id not&quot; =&gt; $_GET['id']),
+			                                             &quot;order&quot; =&gt; &quot;id ASC&quot;));
 		}
 
 		/**
@@ -632,7 +626,7 @@
 				show_403(__(&quot;Access Denied&quot;), __(&quot;You do not have sufficient privileges to manage groups.&quot;));
 
 			if (!empty($_GET['search'])) {
-				$user = new User(null, array(&quot;where&quot; =&gt; &quot;login = :search&quot;, &quot;params&quot; =&gt; array(&quot;:search&quot; =&gt; $_GET['search'])));
+				$user = new User(null, array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $_GET['search'])));
 				$this-&gt;context[&quot;groups&quot;] = array($user-&gt;group());
 			} else
 				$this-&gt;context[&quot;groups&quot;] = new Paginator(Group::find(array(&quot;placeholders&quot; =&gt; true, &quot;order&quot; =&gt; &quot;id ASC&quot;)), 10);</diff>
      <filename>includes/controller/Admin.php</filename>
    </modified>
    <modified>
      <diff>@@ -25,13 +25,11 @@
 
 			if (isset($_GET['day']))
 				$posts = new Paginator(Post::find(array(&quot;placeholders&quot; =&gt; true,
-				                                        &quot;where&quot; =&gt; &quot;created_at LIKE :date&quot;,
-				                                        &quot;params&quot; =&gt; array(&quot;:date&quot; =&gt; $_GET['year'].&quot;-&quot;.$_GET['month'].&quot;-&quot;.$_GET['day'].&quot;%&quot;))),
+				                                        &quot;where&quot; =&gt; array(&quot;created_at like&quot; =&gt; $_GET['year'].&quot;-&quot;.$_GET['month'].&quot;-&quot;.$_GET['day'].&quot;%&quot;))),
 				                       Config::current()-&gt;posts_per_page);
 			else
 				$posts = new Paginator(Post::find(array(&quot;placeholders&quot; =&gt; true,
-				                                        &quot;where&quot; =&gt; &quot;created_at LIKE :date&quot;,
-				                                        &quot;params&quot; =&gt; array(&quot;:date&quot; =&gt; $_GET['year'].&quot;-&quot;.$_GET['month'].&quot;%&quot;))),
+				                                        &quot;where&quot; =&gt; array(&quot;created_at like&quot; =&gt; $_GET['year'].&quot;-&quot;.$_GET['month'].&quot;%&quot;))),
 				                       Config::current()-&gt;posts_per_page);
 		}
 
@@ -70,9 +68,8 @@
 
 			global $posts;
 			$posts = new Paginator(Post::find(array(&quot;placeholders&quot; =&gt; true,
-			                                        &quot;where&quot; =&gt; array(&quot;status = 'draft'&quot;,
-			                                                         &quot;user_id = :current_user&quot;),
-			                                        &quot;params&quot; =&gt; array(&quot;:current_user&quot; =&gt; $visitor-&gt;id))),
+			                                        &quot;where&quot; =&gt; array(&quot;status&quot; =&gt; &quot;draft&quot;,
+			                                                         &quot;user_id&quot; =&gt; $visitor-&gt;id))),
 				                   Config::current()-&gt;posts_per_page);
 		}
 
@@ -84,7 +81,7 @@
 			global $page;
 
 			if (!isset($page))
-				$page = new Page(null, array(&quot;where&quot; =&gt; &quot;url = :url&quot;, &quot;params&quot; =&gt; array(&quot;:url&quot; =&gt; $_GET['url'])));
+				$page = new Page(null, array(&quot;where&quot; =&gt; array(&quot;url&quot; =&gt; $_GET['url'])));
 		}
 
 		/**
@@ -118,8 +115,7 @@
 			$get = array_map(&quot;urldecode&quot;, $_GET);
 
 			if (!$config-&gt;clean_urls)
-				$post = new Post(null, array(&quot;where&quot; =&gt; &quot;url = :url&quot;,
-				                             &quot;params&quot; =&gt; array(&quot;:url&quot; =&gt; fallback($get['url']))));
+				$post = new Post(null, array(&quot;where&quot; =&gt; array(&quot;url&quot; =&gt; fallback($get['url']))));
 			else
 				$post = Post::from_url($route-&gt;post_url_attrs, array(&quot;drafts&quot; =&gt; true));
 
@@ -187,8 +183,7 @@
 			if (empty($_POST['login']))
 				return Flash::warning(__(&quot;Please enter a username for your account.&quot;));
 
-			if (count(User::find(array(&quot;where&quot; =&gt; &quot;login = :login&quot;,
-			                           &quot;params&quot; =&gt; array(&quot;:login&quot; =&gt; $_POST['login'])))))
+			if (count(User::find(array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $_POST['login'])))))
 				Flash::warning(__(&quot;That username is already in use.&quot;));
 
 			if (empty($_POST['password1']) and empty($_POST['password2']))
@@ -227,8 +222,7 @@
 			fallback($_POST['password']);
 
 			if (!User::authenticate($_POST['login'], md5($_POST['password'])))
-				if (!count(User::find(array(&quot;where&quot; =&gt; &quot;login = :login&quot;,
-				                           &quot;params&quot; =&gt; array(&quot;:login&quot; =&gt; $_POST['login'])))))
+				if (!count(User::find(array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $_POST['login'])))))
 					Flash::warning(__(&quot;There is no user with that login name.&quot;));
 				else
 					Flash::warning(__(&quot;Password incorrect.&quot;));
@@ -294,7 +288,7 @@
 			if (empty($_POST))
 				return;
 
-			$user = new User(null, array(&quot;where&quot; =&gt; &quot;login = :login&quot;, &quot;params&quot; =&gt; array(&quot;:login&quot; =&gt; $_POST['login'])));
+			$user = new User(null, array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $_POST['login'])));
 			if ($user-&gt;no_results)
 				return Flash::warning(__(&quot;Invalid user specified.&quot;));
 </diff>
      <filename>includes/controller/Main.php</filename>
    </modified>
    <modified>
      <diff>@@ -1551,17 +1551,14 @@
 				$where[] = strtoupper($test).&quot;(created_at) = :created_&quot;.$test;
 				$params[&quot;:created_&quot;.$test] = $equals;
 			} elseif ($test == &quot;author&quot;) {
-				$user = new User(null, array(&quot;where&quot; =&gt; &quot;login = :login&quot;, &quot;params&quot; =&gt; array(&quot;:login&quot; =&gt; $equals)));
-				$where[] = &quot;user_id = :user_id&quot;;
-				$params[&quot;:user_id&quot;] = $user-&gt;id;
+				$user = new User(null, array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $equals)));
+				$where[&quot;user_id&quot;] = $user-&gt;id;
 			} elseif ($test == &quot;group&quot;) {
-				$group = new Group(null, array(&quot;where&quot; =&gt; &quot;name = :name&quot;, &quot;params&quot; =&gt; array(&quot;:name&quot; =&gt; $equals)));
+				$group = new Group(null, array(&quot;where&quot; =&gt; array(&quot;name&quot; =&gt; $equals)));
 				$test = &quot;group_id&quot;;
 				$equals = ($group-&gt;no_results) ? 0 : $group-&gt;id ;
-			} else {
-				$where[] = $test.&quot; = :&quot;.$test;
-				$params[&quot;:&quot;.$test] = $equals;
-			}
+			} else
+				$where[$test] = $equals;
 		}
 
 		if (!empty($search)) {</diff>
      <filename>includes/helpers.php</filename>
    </modified>
    <modified>
      <diff>@@ -175,8 +175,7 @@
 			if ($this-&gt;no_results)
 				return false;
 
-			return User::find(array(&quot;where&quot; =&gt; &quot;group_id = :group_id&quot;,
-			                        &quot;params&quot; =&gt; array(&quot;:group_id&quot; =&gt; $this-&gt;id)));
+			return User::find(array(&quot;where&quot; =&gt; array(&quot;group_id&quot; =&gt; $this-&gt;id)));
 		}
 
 		/**</diff>
      <filename>includes/model/Group.php</filename>
    </modified>
    <modified>
      <diff>@@ -231,7 +231,7 @@
 			if ($this-&gt;no_results)
 				return false;
 
-			return self::find(array(&quot;where&quot; =&gt; &quot;parent_id = :id&quot;, &quot;params&quot; =&gt; array(&quot;:id&quot; =&gt; $this-&gt;id)));
+			return self::find(array(&quot;where&quot; =&gt; array(&quot;parent_id&quot; =&gt; $this-&gt;id)));
 		}
 
 		/**</diff>
      <filename>includes/model/Page.php</filename>
    </modified>
    <modified>
      <diff>@@ -68,8 +68,8 @@
 				$options[&quot;where&quot;] = array();
 
 			$has_status = false;
-			foreach ($options[&quot;where&quot;] as $where)
-				if (substr_count($where, &quot;status&quot;))
+			foreach ($options[&quot;where&quot;] as $key =&gt; $val)
+				if (is_int($key) and substr_count($val, &quot;status&quot;) or $key == &quot;status&quot;)
 					$has_status = true;
 
 			if (!XML_RPC) {
@@ -351,12 +351,12 @@
 
 			# Can they edit their own posts, and do they have any?
 			if ($visitor-&gt;group()-&gt;can(&quot;edit_own_post&quot;) and
-			    Post::find(array(&quot;where&quot; =&gt; &quot;user_id = :visitor_id&quot;, &quot;params&quot; =&gt; array(&quot;:visitor_id&quot; =&gt; $visitor-&gt;id))))
+			    Post::find(array(&quot;where&quot; =&gt; array(&quot;user_id&quot; =&gt; $visitor-&gt;id))))
 				return true;
 
 			# Can they edit their own drafts, and do they have any?
 			if ($visitor-&gt;group()-&gt;can(&quot;edit_own_draft&quot;) and
-			    Post::find(array(&quot;where&quot; =&gt; &quot;status = 'draft' and user_id = :visitor_id&quot;, &quot;params&quot; =&gt; array(&quot;:visitor_id&quot; =&gt; $visitor-&gt;id))))
+			    Post::find(array(&quot;where&quot; =&gt; array(&quot;status&quot; =&gt; &quot;draft&quot;, &quot;user_id&quot; =&gt; $visitor-&gt;id))))
 				return true;
 
 			return false;
@@ -380,12 +380,12 @@
 
 			# Can they delete their own posts, and do they have any?
 			if ($visitor-&gt;group()-&gt;can(&quot;delete_own_post&quot;) and
-			    Post::find(array(&quot;where&quot; =&gt; &quot;user_id = :visitor_id&quot;, &quot;params&quot; =&gt; array(&quot;:visitor_id&quot; =&gt; $visitor-&gt;id))))
+			    Post::find(array(&quot;where&quot; =&gt; array(&quot;user_id&quot; =&gt; $visitor-&gt;id))))
 				return true;
 
 			# Can they delete their own drafts, and do they have any?
 			if ($visitor-&gt;group()-&gt;can(&quot;delete_own_draft&quot;) and
-			    Post::find(array(&quot;where&quot; =&gt; &quot;status = 'draft' and user_id = :visitor_id&quot;, &quot;params&quot; =&gt; array(&quot;:visitor_id&quot; =&gt; $visitor-&gt;id))))
+			    Post::find(array(&quot;where&quot; =&gt; array(&quot;status&quot; =&gt; &quot;draft&quot;, &quot;user_id&quot; =&gt; $visitor-&gt;id))))
 				return true;
 
 			return false;
@@ -770,19 +770,17 @@
 				if (in_array($attr, $times)) {
 					$where[] = strtoupper($attr).&quot;(created_at) = :created_&quot;.$attr;
 					$params[':created_'.$attr] = $get[$attr];
-				} elseif ($attr == &quot;author&quot;) {
-					$where[] = &quot;user_id = :attrauthor&quot;;
-					$params[':attrauthor'] = SQL::current()-&gt;select(&quot;users&quot;,
+				} elseif ($attr == &quot;author&quot;)
+					$where[&quot;user_id&quot;] = SQL::current()-&gt;select(&quot;users&quot;,
 					                                      &quot;id&quot;,
 					                                      &quot;login = :login&quot;,
 					                                      &quot;id&quot;,
 					                                      array(
 					                                          &quot;:login&quot; =&gt; $get['author']
 					                                      ), 1)-&gt;fetchColumn();
-				} elseif ($attr == &quot;feathers&quot;) {
-					$where[] = &quot;feather = :feather&quot;;
-					$params[':feather'] = depluralize($get['feathers']);
-				} else {
+				elseif ($attr == &quot;feathers&quot;)
+					$where[&quot;feather&quot;] = depluralize($get['feathers']);
+				else {
 					$tokens = array($where, $params, $attr);
 					Trigger::current()-&gt;filter($tokens, &quot;post_url_token&quot;);
 					list($where, $params, $attr) = $tokens;</diff>
      <filename>includes/model/Post.php</filename>
    </modified>
    <modified>
      <diff>@@ -42,8 +42,7 @@
 		 *     true - if a match is found.
 		 */
 		static function authenticate($login, $password) {
-			$check = new self(null, array(&quot;where&quot; =&gt; array(&quot;login = :login&quot;, &quot;password = :password&quot;),
-			                              &quot;params&quot; =&gt; array(&quot;:login&quot; =&gt; $login, &quot;:password&quot; =&gt; $password)));
+			$check = new self(null, array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $login, &quot;password&quot; =&gt; $password)));
 			return !$check-&gt;no_results;
 		}
 
@@ -167,8 +166,7 @@
 			if ($this-&gt;no_results)
 				return false;
 
-			return Post::find(array(&quot;where&quot; =&gt; &quot;user_id = :user_id&quot;,
-			                        &quot;params&quot; =&gt; array(&quot;:user_id&quot; =&gt; $this-&gt;id)));
+			return Post::find(array(&quot;where&quot; =&gt; array(&quot;user_id&quot; =&gt; $this-&gt;id)));
 		}
 
 		/**
@@ -179,8 +177,7 @@
 			if ($this-&gt;no_results)
 				return false;
 
-			return Page::find(array(&quot;where&quot; =&gt; &quot;user_id = :user_id&quot;,
-			                        &quot;params&quot; =&gt; array(&quot;:user_id&quot; =&gt; $this-&gt;id)));
+			return Page::find(array(&quot;where&quot; =&gt; array(&quot;user_id&quot; =&gt; $this-&gt;id)));
 		}
 
 		/**</diff>
      <filename>includes/model/User.php</filename>
    </modified>
    <modified>
      <diff>@@ -16,10 +16,8 @@
 		 */
 		public function __construct() {
 			if (isset($_SESSION['login']) and isset($_SESSION['password']))
-				parent::__construct(null, array(&quot;where&quot;  =&gt; array(&quot;login = :login&quot;,
-				                                                  &quot;password = :password&quot;),
-				                                &quot;params&quot; =&gt; array(&quot;:login&quot;    =&gt; $_SESSION['login'],
-				                                                  &quot;:password&quot; =&gt; $_SESSION['password'])));
+				parent::__construct(null, array(&quot;where&quot;  =&gt; array(&quot;login&quot;    =&gt; $_SESSION['login'],
+				                                                  &quot;password&quot; =&gt; $_SESSION['password'])));
 		}
 
 		/**</diff>
      <filename>includes/model/Visitor.php</filename>
    </modified>
    <modified>
      <diff>@@ -86,8 +86,7 @@
 					                              &quot;timestamp&quot; =&gt; $timestamp,
 					                              &quot;url&quot; =&gt; url(&quot;archive/&quot;.when(&quot;Y/m/&quot;, $time-&gt;created_at)));
 
-					$archives[$timestamp][&quot;posts&quot;] = Post::find(array(&quot;where&quot; =&gt; &quot;created_at LIKE :created_at&quot;,
-					                                                  &quot;params&quot; =&gt; array(&quot;:created_at&quot; =&gt; when(&quot;Y-m&quot;, $time-&gt;created_at).&quot;%&quot;)));
+					$archives[$timestamp][&quot;posts&quot;] = Post::find(array(&quot;where&quot; =&gt; array(&quot;created_at like&quot; =&gt; when(&quot;Y-m&quot;, $time-&gt;created_at).&quot;%&quot;)));
 				}
 
 				$theme-&gt;load(&quot;pages/archive&quot;, array(&quot;archives&quot; =&gt; $archives));</diff>
      <filename>index.php</filename>
    </modified>
    <modified>
      <diff>@@ -697,8 +697,7 @@
 		}
 
 		public function posts_export($atom, $post) {
-			$comments = Comment::find(array(&quot;where&quot; =&gt; &quot;post_id = :post_id&quot;,
-			                                &quot;params&quot; =&gt; array(&quot;:post_id&quot; =&gt; $post-&gt;id)),
+			$comments = Comment::find(array(&quot;where&quot; =&gt; array(&quot;post_id&quot; =&gt; $post-&gt;id)),
 			                          array(&quot;filter&quot; =&gt; false));
 
 			foreach ($comments as $comment) {</diff>
      <filename>modules/comments/comments.php</filename>
    </modified>
    <modified>
      <diff>@@ -248,7 +248,7 @@
 
 			# Can they edit their own comments, and do they have any?
 			if ($visitor-&gt;group()-&gt;can(&quot;edit_own_comment&quot;) and
-			    self::find(array(&quot;where&quot; =&gt; &quot;user_id = :visitor_id&quot;, &quot;params&quot; =&gt; array(&quot;:visitor_id&quot; =&gt; $visitor-&gt;id))))
+			    self::find(array(&quot;where&quot; =&gt; array(&quot;user_id&quot; =&gt; $visitor-&gt;id))))
 				return true;
 
 			return false;
@@ -267,7 +267,7 @@
 
 			# Can they delete their own comments, and do they have any?
 			if ($visitor-&gt;group()-&gt;can(&quot;delete_own_comment&quot;) and
-			    self::find(array(&quot;where&quot; =&gt; &quot;user_id = :visitor_id&quot;, &quot;params&quot; =&gt; array(&quot;:visitor_id&quot; =&gt; $visitor-&gt;id))))
+			    self::find(array(&quot;where&quot; =&gt; array(&quot;user_id&quot; =&gt; $visitor-&gt;id))))
 				return true;
 
 			return false;</diff>
      <filename>modules/comments/model.Comment.php</filename>
    </modified>
    <modified>
      <diff>@@ -179,7 +179,7 @@
 				$clean[] = $tag[&quot;clean&quot;];
 			}
 
-			list($tags, $clean, $tag2clean) = $this-&gt;parseTags($tags, $clean);
+			list($tags, $clean, $tag2clean,) = self::parseTags($tags, $clean);
 
 			$max_qty = max(array_values($tags));
 			$min_qty = min(array_values($tags));
@@ -208,15 +208,13 @@
 			list($where, $params) = keywords(urldecode($_GET['query']), &quot;xml LIKE :query&quot;);
 
 			$visitor = Visitor::current();
-			if (!$visitor-&gt;group()-&gt;can(&quot;view_draft&quot;, &quot;edit_draft&quot;, &quot;edit_post&quot;, &quot;delete_draft&quot;, &quot;delete_post&quot;)) {
-				$where[] = &quot;user_id = :visitor_id&quot;;
-				$params[':visitor_id'] = $visitor-&gt;id;
-			}
+			if (!$visitor-&gt;group()-&gt;can(&quot;view_draft&quot;, &quot;edit_draft&quot;, &quot;edit_post&quot;, &quot;delete_draft&quot;, &quot;delete_post&quot;))
+				$where[&quot;user_id&quot;] = $visitor-&gt;id;
 
 			$admin-&gt;context[&quot;posts&quot;] = new Paginator(Post::find(array(&quot;placeholders&quot; =&gt; true,
-			                                                         &quot;drafts&quot; =&gt; true,
-			                                                         &quot;where&quot; =&gt; $where,
-			                                                         &quot;params&quot; =&gt; $params)), 25);
+			                                                          &quot;drafts&quot; =&gt; true,
+			                                                          &quot;where&quot; =&gt; $where,
+			                                                          &quot;params&quot; =&gt; $params)), 25);
 		}
 
 		public function admin_rename_tag($admin) {
@@ -239,7 +237,7 @@
 				$clean[] = $tag[&quot;clean&quot;];
 			}
 
-			list($tags, $clean, $tag2clean) = $this-&gt;parseTags($tags, $clean);
+			list($tags, $clean, $tag2clean,) = self::parseTags($tags, $clean);
 
 			foreach ($tags as $tag =&gt; $count)
 				if ($tag2clean[$tag] == $_GET['name'])
@@ -348,8 +346,7 @@
 			global $posts;
 
 			$posts = new Paginator(Post::find(array(&quot;placeholders&quot; =&gt; true,
-			                                        &quot;where&quot; =&gt; &quot;tags.clean LIKE :tag&quot;,
-			                                        &quot;params&quot; =&gt; array(&quot;:tag&quot; =&gt; &quot;%{{&quot;.$_GET['name'].&quot;}}%&quot;))),
+			                                        &quot;where&quot; =&gt; array(&quot;tags.clean like&quot; =&gt; &quot;%{{&quot;.$_GET['name'].&quot;}}%&quot;))),
 			                       Config::current()-&gt;posts_per_page);
 
 			return !empty($posts-&gt;paginated);
@@ -505,7 +502,7 @@
 				return;
 			}
 
-			list($tags, $clean, $tag2clean) = $this-&gt;parseTags(array($post-&gt;unclean_tags), array($post-&gt;clean_tags));
+			list($tags, $clean, $tag2clean,) = self::parseTags(array($post-&gt;unclean_tags), array($post-&gt;clean_tags));
 
 			$post-&gt;tags = array();
 
@@ -557,7 +554,7 @@
 			if (!count($unclean))
 				return array();
 
-			list($unclean, $clean, $tag2clean) = $this-&gt;parseTags($unclean, $clean);
+			list($unclean, $clean, $tag2clean,) = self::parseTags($unclean, $clean);
 
 			foreach ($unclean as $name =&gt; $popularity)
 				$unclean[$name] = array(&quot;name&quot; =&gt; $name, &quot;popularity&quot; =&gt; $popularity, &quot;url&quot; =&gt; $tag2clean[$name]);
@@ -581,7 +578,7 @@
 				$clean[] = $tag[&quot;clean&quot;];
 			}
 
-			list($tags, $clean, $tag2clean) = $this-&gt;parseTags($tags, $clean);
+			list($tags, $clean, $tag2clean, $clean2tag) = self::parseTags($tags, $clean);
 
 			return $clean2tag[$clean_tag];
 		}
@@ -594,7 +591,7 @@
 				$clean[] = $tag[&quot;clean&quot;];
 			}
 
-			list($tags, $clean, $tag2clean) = $this-&gt;parseTags($tags, $clean);
+			list($tags, $clean, $tag2clean) = self::parseTags($tags, $clean);
 
 			return $tag2clean[$unclean_tag];
 		}
@@ -658,10 +655,11 @@
 		# array(&quot;foo&quot;, &quot;bar&quot;, &quot;foo&quot;)
 		# to
 		# array(&quot;foo&quot; =&gt; 2, &quot;bar&quot; =&gt; 1)
-		public function parseTags($tags, $clean) {
+		static function parseTags($tags, $clean) {
 			$tags = array_count_values(explode(&quot;,&quot;, preg_replace(&quot;/\{\{([^\}]+)\}\}/&quot;, &quot;\\1&quot;, implode(&quot;,&quot;, $tags))));
 			$clean = array_count_values(explode(&quot;,&quot;, preg_replace(&quot;/\{\{([^\}]+)\}\}/&quot;, &quot;\\1&quot;, implode(&quot;,&quot;, $clean))));
 			$tag2clean = array_combine(array_keys($tags), array_keys($clean));
-			return array($tags, $clean, $tag2clean);
+			$clean2tag = array_combine(array_keys($clean), array_keys($tags));
+			return array($tags, $clean, $tag2clean, $clean2tag);
 		}
 	}</diff>
      <filename>modules/tags/tags.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>836e49726831a263f49b0cab82ad1a9ba2ca42e9</id>
    </parent>
  </parents>
  <author>
    <name>Alex Suraci</name>
    <email>i.am@toogeneric.com</email>
  </author>
  <url>http://github.com/vito/chyrp/commit/a7f35ec512c10340723dacfb6f141c0f42a42749</url>
  <id>a7f35ec512c10340723dacfb6f141c0f42a42749</id>
  <committed-date>2008-09-01T08:38:00-07:00</committed-date>
  <authored-date>2008-09-01T08:38:00-07:00</authored-date>
  <message>* Vastly improved SQL interfacing. [#200 state:resolved]
* Moved `escape` function from Query class to SQL class. Also, it now auto-quotes the value like PDO does.</message>
  <tree>6d188879ca0b09c16c21c986427bc96ed1e4acd1</tree>
  <committer>
    <name>Alex Suraci</name>
    <email>i.am@toogeneric.com</email>
  </committer>
</commit>
