diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-06-06 16:57:52 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-06-06 16:57:52 +0000 |
commit | c3e95d2532f9416303cd54af295616336d306f91 (patch) | |
tree | 4a9b28c3e4a6e36fa336a25504274dcbb52c5434 /includes | |
parent | 7442dc060f4c58a62de98b0437dbb2d2137ed59c (diff) | |
download | brdo-c3e95d2532f9416303cd54af295616336d306f91.tar.gz brdo-c3e95d2532f9416303cd54af295616336d306f91.tar.bz2 |
#483808 by chx and Crell: Default DBTNG conditions to IN when an array of values is passed in, to match the field query API.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/database/query.inc | 25 | ||||
-rw-r--r-- | includes/database/select.inc | 2 |
2 files changed, 11 insertions, 16 deletions
diff --git a/includes/database/query.inc b/includes/database/query.inc index ac14c4a2e..f1aed5e52 100644 --- a/includes/database/query.inc +++ b/includes/database/query.inc @@ -31,10 +31,8 @@ interface QueryConditionInterface { * dependent on the $operator. * @param $operator * The comparison operator, such as =, <, or >=. It also accepts more complex - * options such as IN, LIKE, or BETWEEN. - * @param $num_args - * For internal use only. This argument is used to track the recursive calls when - * processing complex conditions. + * options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array + * = otherwise. * @return * The called object. */ @@ -794,11 +792,8 @@ class DeleteQuery extends Query implements QueryConditionInterface { $this->condition = new DatabaseCondition('AND'); } - public function condition($field, $value = NULL, $operator = '=') { - if (!isset($num_args)) { - $num_args = func_num_args(); - } - $this->condition->condition($field, $value, $operator, $num_args); + public function condition($field, $value = NULL, $operator = NULL) { + $this->condition->condition($field, $value, $operator); return $this; } @@ -939,11 +934,8 @@ class UpdateQuery extends Query implements QueryConditionInterface { $this->condition = new DatabaseCondition('AND'); } - public function condition($field, $value = NULL, $operator = '=') { - if (!isset($num_args)) { - $num_args = func_num_args(); - } - $this->condition->condition($field, $value, $operator, $num_args); + public function condition($field, $value = NULL, $operator = NULL) { + $this->condition->condition($field, $value, $operator); return $this; } @@ -1094,7 +1086,10 @@ class DatabaseCondition implements QueryConditionInterface, Countable { return count($this->conditions) - 1; } - public function condition($field, $value = NULL, $operator = '=') { + public function condition($field, $value = NULL, $operator = NULL) { + if (!isset($operator)) { + $operator = is_array($value) ? 'IN' : '='; + } $this->conditions[] = array( 'field' => $field, 'value' => $value, diff --git a/includes/database/select.inc b/includes/database/select.inc index 65b31bc6c..449ab11f4 100644 --- a/includes/database/select.inc +++ b/includes/database/select.inc @@ -423,7 +423,7 @@ class SelectQueryExtender implements SelectQueryInterface { /* Implementations of QueryConditionInterface for the WHERE clause. */ - public function condition($field, $value = NULL, $operator = '=') { + public function condition($field, $value = NULL, $operator = NULL) { $this->query->condition($field, $value, $operator); return $this; } |