diff --git a/includes/database/query.inc b/includes/database/query.inc index ac14c4a2e5e77cc610d61130239ae812a6e7adf1..f1aed5e52aed0f7eee465bd5cc960db5739c04fe 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 @@ public function __construct(DatabaseConnection $connection, $table, array $optio $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 @@ public function __construct(DatabaseConnection $connection, $table, array $optio $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 @@ public function count() { 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 65b31bc6cacdea4be5b318d429730753424ce8ad..449ab11f4527b113f41fa08bea51fd8f6c19c845 100644 --- a/includes/database/select.inc +++ b/includes/database/select.inc @@ -423,7 +423,7 @@ public function getMetaData($key) { /* 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; }