{"action":"created","comment":{"url":"https://api.github.com/repos/yiisoft/yii2/pulls/comments/30788707","id":30788707,"diff_hunk":"@@ -375,4 +375,35 @@ public function offset($offset)\n         $this->offset = $offset;\n         return $this;\n     }\n+\n+    /**\n+     * Helper method for easy querying on values containing some common operators.\n+     *\n+     * The comparison operator is intelligently determined based on the first few characters in the given value. In particular, it recognizes the following operators if they appear as the leading characters in the given value:\n+     * <: the column must be less than the given value.\n+     * >: the column must be greater than the given value.\n+     * <=: the column must be less than or equal to the given value.\n+     * >=: the column must be greater than or equal to the given value.\n+     * <>: the column must not be the same as the given value. Note that when $partialMatch is true, this would mean the value must not be a substring of the column.\n+     * =: the column must be equal to the given value.\n+     * none of the above: use the $defaultOperator\n+     *\n+     * Note that when the value is empty, no comparison expression will be added to the search condition.\n+     *\n+     * @param string $name column name\n+     * @param scalar $value column value\n+     * @param string $defaultOperator Defaults to =, performing an exact match.\n+     * For example: use 'like' for partial matching\n+     */\n+    public function andFilterCompare($name, $value, $defaultOperator = '=')\n+    {\n+        $matches=[];\n+        if (preg_match(\"/^(<>|>=|>|<=|<|=)/\", $value, $matches)) {\n+            $op = $matches[1];\n+            $value = substr($value, strlen($op));\n+        } else {\n+            $op = $defaultOperator;\n+        }\n+        $this->andFilterWhere([$op, $name, $value]);","path":"framework/db/QueryTrait.php","position":33,"original_position":33,"commit_id":"68943a168be8d3fe8010c8b597a6150500527cd4","original_commit_id":"68943a168be8d3fe8010c8b597a6150500527cd4","user":{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false},"body":"This will fail for NOSQL queries such as `yii\\elasticsearhc\\Query` or `yii\\mongodb\\Query`","created_at":"2015-05-21T10:08:53Z","updated_at":"2015-05-21T10:08:53Z","html_url":"https://github.com/yiisoft/yii2/pull/8505#discussion_r30788707","pull_request_url":"https://api.github.com/repos/yiisoft/yii2/pulls/8505","_links":{"self":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/comments/30788707"},"html":{"href":"https://github.com/yiisoft/yii2/pull/8505#discussion_r30788707"},"pull_request":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/8505"}}},"pull_request":{"url":"https://api.github.com/repos/yiisoft/yii2/pulls/8505","id":35918212,"html_url":"https://github.com/yiisoft/yii2/pull/8505","diff_url":"https://github.com/yiisoft/yii2/pull/8505.diff","patch_url":"https://github.com/yiisoft/yii2/pull/8505.patch","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8505","number":8505,"state":"open","locked":false,"title":"Query helper method for filter values containing operators","user":{"login":"lennartvdd","id":1104561,"avatar_url":"https://avatars.githubusercontent.com/u/1104561?v=3","gravatar_id":"","url":"https://api.github.com/users/lennartvdd","html_url":"https://github.com/lennartvdd","followers_url":"https://api.github.com/users/lennartvdd/followers","following_url":"https://api.github.com/users/lennartvdd/following{/other_user}","gists_url":"https://api.github.com/users/lennartvdd/gists{/gist_id}","starred_url":"https://api.github.com/users/lennartvdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lennartvdd/subscriptions","organizations_url":"https://api.github.com/users/lennartvdd/orgs","repos_url":"https://api.github.com/users/lennartvdd/repos","events_url":"https://api.github.com/users/lennartvdd/events{/privacy}","received_events_url":"https://api.github.com/users/lennartvdd/received_events","type":"User","site_admin":false},"body":"Basic implementation proposal for yiisoft/yii2#2022\r\n\r\nShortcomings/todo's:\r\n* filtering on non-scalars (where IN statements) not supported\r\n* Numeric properties with a corresponding validation rule will yield\r\n  errors when they contain an alphanumeric operator. These properties'\r\n  rules should be defined as 'string' or 'safe'.\r\n* no implementation example in Gii code (yet).","created_at":"2015-05-21T10:05:52Z","updated_at":"2015-05-21T10:08:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c3da45a3fda2349c572bc33949a16cd4f8e0a6b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yiisoft/yii2/pulls/8505/commits","review_comments_url":"https://api.github.com/repos/yiisoft/yii2/pulls/8505/comments","review_comment_url":"https://api.github.com/repos/yiisoft/yii2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8505/comments","statuses_url":"https://api.github.com/repos/yiisoft/yii2/statuses/68943a168be8d3fe8010c8b597a6150500527cd4","head":{"label":"lennartvdd:queryCompare","ref":"queryCompare","sha":"68943a168be8d3fe8010c8b597a6150500527cd4","user":{"login":"lennartvdd","id":1104561,"avatar_url":"https://avatars.githubusercontent.com/u/1104561?v=3","gravatar_id":"","url":"https://api.github.com/users/lennartvdd","html_url":"https://github.com/lennartvdd","followers_url":"https://api.github.com/users/lennartvdd/followers","following_url":"https://api.github.com/users/lennartvdd/following{/other_user}","gists_url":"https://api.github.com/users/lennartvdd/gists{/gist_id}","starred_url":"https://api.github.com/users/lennartvdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lennartvdd/subscriptions","organizations_url":"https://api.github.com/users/lennartvdd/orgs","repos_url":"https://api.github.com/users/lennartvdd/repos","events_url":"https://api.github.com/users/lennartvdd/events{/privacy}","received_events_url":"https://api.github.com/users/lennartvdd/received_events","type":"User","site_admin":false},"repo":{"id":35975776,"name":"yii2","full_name":"lennartvdd/yii2","owner":{"login":"lennartvdd","id":1104561,"avatar_url":"https://avatars.githubusercontent.com/u/1104561?v=3","gravatar_id":"","url":"https://api.github.com/users/lennartvdd","html_url":"https://github.com/lennartvdd","followers_url":"https://api.github.com/users/lennartvdd/followers","following_url":"https://api.github.com/users/lennartvdd/following{/other_user}","gists_url":"https://api.github.com/users/lennartvdd/gists{/gist_id}","starred_url":"https://api.github.com/users/lennartvdd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lennartvdd/subscriptions","organizations_url":"https://api.github.com/users/lennartvdd/orgs","repos_url":"https://api.github.com/users/lennartvdd/repos","events_url":"https://api.github.com/users/lennartvdd/events{/privacy}","received_events_url":"https://api.github.com/users/lennartvdd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lennartvdd/yii2","description":"Yii 2 framework main development repo","fork":true,"url":"https://api.github.com/repos/lennartvdd/yii2","forks_url":"https://api.github.com/repos/lennartvdd/yii2/forks","keys_url":"https://api.github.com/repos/lennartvdd/yii2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lennartvdd/yii2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lennartvdd/yii2/teams","hooks_url":"https://api.github.com/repos/lennartvdd/yii2/hooks","issue_events_url":"https://api.github.com/repos/lennartvdd/yii2/issues/events{/number}","events_url":"https://api.github.com/repos/lennartvdd/yii2/events","assignees_url":"https://api.github.com/repos/lennartvdd/yii2/assignees{/user}","branches_url":"https://api.github.com/repos/lennartvdd/yii2/branches{/branch}","tags_url":"https://api.github.com/repos/lennartvdd/yii2/tags","blobs_url":"https://api.github.com/repos/lennartvdd/yii2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lennartvdd/yii2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lennartvdd/yii2/git/refs{/sha}","trees_url":"https://api.github.com/repos/lennartvdd/yii2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lennartvdd/yii2/statuses/{sha}","languages_url":"https://api.github.com/repos/lennartvdd/yii2/languages","stargazers_url":"https://api.github.com/repos/lennartvdd/yii2/stargazers","contributors_url":"https://api.github.com/repos/lennartvdd/yii2/contributors","subscribers_url":"https://api.github.com/repos/lennartvdd/yii2/subscribers","subscription_url":"https://api.github.com/repos/lennartvdd/yii2/subscription","commits_url":"https://api.github.com/repos/lennartvdd/yii2/commits{/sha}","git_commits_url":"https://api.github.com/repos/lennartvdd/yii2/git/commits{/sha}","comments_url":"https://api.github.com/repos/lennartvdd/yii2/comments{/number}","issue_comment_url":"https://api.github.com/repos/lennartvdd/yii2/issues/comments{/number}","contents_url":"https://api.github.com/repos/lennartvdd/yii2/contents/{+path}","compare_url":"https://api.github.com/repos/lennartvdd/yii2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lennartvdd/yii2/merges","archive_url":"https://api.github.com/repos/lennartvdd/yii2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lennartvdd/yii2/downloads","issues_url":"https://api.github.com/repos/lennartvdd/yii2/issues{/number}","pulls_url":"https://api.github.com/repos/lennartvdd/yii2/pulls{/number}","milestones_url":"https://api.github.com/repos/lennartvdd/yii2/milestones{/number}","notifications_url":"https://api.github.com/repos/lennartvdd/yii2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lennartvdd/yii2/labels{/name}","releases_url":"https://api.github.com/repos/lennartvdd/yii2/releases{/id}","created_at":"2015-05-20T21:41:20Z","updated_at":"2015-05-20T21:41:24Z","pushed_at":"2015-05-21T10:07:02Z","git_url":"git://github.com/lennartvdd/yii2.git","ssh_url":"git@github.com:lennartvdd/yii2.git","clone_url":"https://github.com/lennartvdd/yii2.git","svn_url":"https://github.com/lennartvdd/yii2","homepage":"http://www.yiiframework.com","size":37291,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"yiisoft:master","ref":"master","sha":"49b62a7b6b103703bd8fcc7bc7af1070426ee5de","user":{"login":"yiisoft","id":993323,"avatar_url":"https://avatars.githubusercontent.com/u/993323?v=3","gravatar_id":"","url":"https://api.github.com/users/yiisoft","html_url":"https://github.com/yiisoft","followers_url":"https://api.github.com/users/yiisoft/followers","following_url":"https://api.github.com/users/yiisoft/following{/other_user}","gists_url":"https://api.github.com/users/yiisoft/gists{/gist_id}","starred_url":"https://api.github.com/users/yiisoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yiisoft/subscriptions","organizations_url":"https://api.github.com/users/yiisoft/orgs","repos_url":"https://api.github.com/users/yiisoft/repos","events_url":"https://api.github.com/users/yiisoft/events{/privacy}","received_events_url":"https://api.github.com/users/yiisoft/received_events","type":"Organization","site_admin":false},"repo":{"id":3431193,"name":"yii2","full_name":"yiisoft/yii2","owner":{"login":"yiisoft","id":993323,"avatar_url":"https://avatars.githubusercontent.com/u/993323?v=3","gravatar_id":"","url":"https://api.github.com/users/yiisoft","html_url":"https://github.com/yiisoft","followers_url":"https://api.github.com/users/yiisoft/followers","following_url":"https://api.github.com/users/yiisoft/following{/other_user}","gists_url":"https://api.github.com/users/yiisoft/gists{/gist_id}","starred_url":"https://api.github.com/users/yiisoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yiisoft/subscriptions","organizations_url":"https://api.github.com/users/yiisoft/orgs","repos_url":"https://api.github.com/users/yiisoft/repos","events_url":"https://api.github.com/users/yiisoft/events{/privacy}","received_events_url":"https://api.github.com/users/yiisoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yiisoft/yii2","description":"Yii 2 framework main development repo","fork":false,"url":"https://api.github.com/repos/yiisoft/yii2","forks_url":"https://api.github.com/repos/yiisoft/yii2/forks","keys_url":"https://api.github.com/repos/yiisoft/yii2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yiisoft/yii2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yiisoft/yii2/teams","hooks_url":"https://api.github.com/repos/yiisoft/yii2/hooks","issue_events_url":"https://api.github.com/repos/yiisoft/yii2/issues/events{/number}","events_url":"https://api.github.com/repos/yiisoft/yii2/events","assignees_url":"https://api.github.com/repos/yiisoft/yii2/assignees{/user}","branches_url":"https://api.github.com/repos/yiisoft/yii2/branches{/branch}","tags_url":"https://api.github.com/repos/yiisoft/yii2/tags","blobs_url":"https://api.github.com/repos/yiisoft/yii2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yiisoft/yii2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yiisoft/yii2/git/refs{/sha}","trees_url":"https://api.github.com/repos/yiisoft/yii2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yiisoft/yii2/statuses/{sha}","languages_url":"https://api.github.com/repos/yiisoft/yii2/languages","stargazers_url":"https://api.github.com/repos/yiisoft/yii2/stargazers","contributors_url":"https://api.github.com/repos/yiisoft/yii2/contributors","subscribers_url":"https://api.github.com/repos/yiisoft/yii2/subscribers","subscription_url":"https://api.github.com/repos/yiisoft/yii2/subscription","commits_url":"https://api.github.com/repos/yiisoft/yii2/commits{/sha}","git_commits_url":"https://api.github.com/repos/yiisoft/yii2/git/commits{/sha}","comments_url":"https://api.github.com/repos/yiisoft/yii2/comments{/number}","issue_comment_url":"https://api.github.com/repos/yiisoft/yii2/issues/comments{/number}","contents_url":"https://api.github.com/repos/yiisoft/yii2/contents/{+path}","compare_url":"https://api.github.com/repos/yiisoft/yii2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yiisoft/yii2/merges","archive_url":"https://api.github.com/repos/yiisoft/yii2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yiisoft/yii2/downloads","issues_url":"https://api.github.com/repos/yiisoft/yii2/issues{/number}","pulls_url":"https://api.github.com/repos/yiisoft/yii2/pulls{/number}","milestones_url":"https://api.github.com/repos/yiisoft/yii2/milestones{/number}","notifications_url":"https://api.github.com/repos/yiisoft/yii2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yiisoft/yii2/labels{/name}","releases_url":"https://api.github.com/repos/yiisoft/yii2/releases{/id}","created_at":"2012-02-13T15:32:36Z","updated_at":"2015-05-21T09:34:52Z","pushed_at":"2015-05-21T10:07:03Z","git_url":"git://github.com/yiisoft/yii2.git","ssh_url":"git@github.com:yiisoft/yii2.git","clone_url":"https://github.com/yiisoft/yii2.git","svn_url":"https://github.com/yiisoft/yii2","homepage":"http://www.yiiframework.com","size":95532,"stargazers_count":5773,"watchers_count":5773,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3220,"mirror_url":null,"open_issues_count":734,"forks":3220,"open_issues":734,"watchers":5773,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/8505"},"html":{"href":"https://github.com/yiisoft/yii2/pull/8505"},"issue":{"href":"https://api.github.com/repos/yiisoft/yii2/issues/8505"},"comments":{"href":"https://api.github.com/repos/yiisoft/yii2/issues/8505/comments"},"review_comments":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/8505/comments"},"review_comment":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/8505/commits"},"statuses":{"href":"https://api.github.com/repos/yiisoft/yii2/statuses/68943a168be8d3fe8010c8b597a6150500527cd4"}}}}