From cf8b0ae07e2757b5c41ecc65938c8125ba981dea Mon Sep 17 00:00:00 2001 From: githubjeka Date: Wed, 27 May 2015 22:16:30 +0300 Subject: [PATCH] refactoring --- framework/db/Query.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/framework/db/Query.php b/framework/db/Query.php index 72a98e4b313..3bb77738c89 100644 --- a/framework/db/Query.php +++ b/framework/db/Query.php @@ -841,21 +841,16 @@ public static function create($from) * * Note that when the value is empty, no comparison expression will be added to the search condition. * - * @param string $name column name - * @param scalar $value column value - * @param string $defaultOperator Defaults to =, performing an exact match. - * For example: use 'like' for partial matching + * @param string $column name of column + * @param mixed $value value that will be checked + * @param string $operator Defaults to =, performing an exact match. For example: use 'like' for partial matching * @return static The query object itself */ - public function andFilterCompare($name, $value, $defaultOperator = '=') + public function andFilterCompare($column, $value, $operator = '=') { - $matches=[]; - if (preg_match("/^(<>|>=|>|<=|<|=)/", $value, $matches)) { - $op = $matches[1]; - $value = substr($value, strlen($op)); - } else { - $op = $defaultOperator; + if (preg_match("/^(?<>|>=|>|<=|<|=)(?.*)/", $value, $matches)) { + extract($matches); } - return $this->andFilterWhere([$op, $name, $value]); + return $this->andFilterWhere([$operator, $column, $value]); } }