diff options
author | Jamie Matthews <[email protected]> | 2010-04-28 19:46:36 +0100 |
---|---|---|
committer | Jamie Matthews <[email protected]> | 2010-04-28 19:46:36 +0100 |
commit | 036f470e75e25a17e15dcc38c3bc22d2fca0ee88 (patch) | |
tree | b44416b270a4ed3de9dff22818f6a44136af5d74 /idiorm.php | |
parent | 09f0f74ff068891752883fbfa792b7bd29f4df00 (diff) |
Refactor WHERE clause building loop
Diffstat (limited to 'idiorm.php')
-rw-r--r-- | idiorm.php | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -430,24 +430,19 @@ $query[] = $this->raw_where_clause; $this->values = array_merge($this->values, $this->raw_where_parameters); } else if (count($this->where) > 0) { // Standard WHERE clauses - $query[] = "WHERE"; - $first = array_shift($this->where); - $query[] = join(" ", array( - $first[self::WHERE_COLUMN_NAME], - $first[self::WHERE_OPERATOR], - '?' - )); - $this->values[] = $first[self::WHERE_VALUE]; + $where_clauses = array(); while($where = array_shift($this->where)) { - $query[] = "AND"; - $query[] = join(" ", array( + $where_clauses[] = join(" ", array( $where[self::WHERE_COLUMN_NAME], $where[self::WHERE_OPERATOR], '?' )); $this->values[] = $where[self::WHERE_VALUE]; } + + $query[] = "WHERE"; + $query[] = join(" AND ", $where_clauses); } // Add ORDER BY clause(s) |