{"action":"created","comment":{"url":"https://api.github.com/repos/yiisoft/yii2/pulls/comments/66028652","id":66028652,"diff_hunk":"@@ -806,7 +806,7 @@ public function alias($alias)\n      * @param string|array $condition the given conditions\n      * @param string $aliasName\n      */\n-    private function replaceAliasPlaceholder($condition, $aliasName)\n+    public function replaceAliasPlaceholder($condition, $aliasName)","path":"framework/db/ActiveQuery.php","position":null,"original_position":5,"commit_id":"5c3f7d158852d49a2b1ca0566a474d5527287790","original_commit_id":"5c3f7d158852d49a2b1ca0566a474d5527287790","user":{"login":"CedricYii","id":14201156,"avatar_url":"https://avatars.githubusercontent.com/u/14201156?v=3","gravatar_id":"","url":"https://api.github.com/users/CedricYii","html_url":"https://github.com/CedricYii","followers_url":"https://api.github.com/users/CedricYii/followers","following_url":"https://api.github.com/users/CedricYii/following{/other_user}","gists_url":"https://api.github.com/users/CedricYii/gists{/gist_id}","starred_url":"https://api.github.com/users/CedricYii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CedricYii/subscriptions","organizations_url":"https://api.github.com/users/CedricYii/orgs","repos_url":"https://api.github.com/users/CedricYii/repos","events_url":"https://api.github.com/users/CedricYii/events{/privacy}","received_events_url":"https://api.github.com/users/CedricYii/received_events","type":"User","site_admin":false},"body":"It's not needed but wouldn't hurt as @lynicidn suggested.\r\nFor some reasons I don't know, methods (removeDuplicatedModels, buildJoinWith, getQueryTableName, ...) are in private so I sticked to it for normalizeAliasInQuery. However I would have put it in protected.\r\n","created_at":"2016-06-07T08:27:14Z","updated_at":"2016-06-07T08:27:14Z","html_url":"https://github.com/yiisoft/yii2/pull/11646#discussion_r66028652","pull_request_url":"https://api.github.com/repos/yiisoft/yii2/pulls/11646","_links":{"self":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/comments/66028652"},"html":{"href":"https://github.com/yiisoft/yii2/pull/11646#discussion_r66028652"},"pull_request":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/11646"}}},"pull_request":{"url":"https://api.github.com/repos/yiisoft/yii2/pulls/11646","id":71691432,"html_url":"https://github.com/yiisoft/yii2/pull/11646","diff_url":"https://github.com/yiisoft/yii2/pull/11646.diff","patch_url":"https://github.com/yiisoft/yii2/pull/11646.patch","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/11646","number":11646,"state":"open","locked":false,"title":"Added dynamic alias '@alias' in ActiveQuery","user":{"login":"CedricYii","id":14201156,"avatar_url":"https://avatars.githubusercontent.com/u/14201156?v=3","gravatar_id":"","url":"https://api.github.com/users/CedricYii","html_url":"https://github.com/CedricYii","followers_url":"https://api.github.com/users/CedricYii/followers","following_url":"https://api.github.com/users/CedricYii/following{/other_user}","gists_url":"https://api.github.com/users/CedricYii/gists{/gist_id}","starred_url":"https://api.github.com/users/CedricYii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CedricYii/subscriptions","organizations_url":"https://api.github.com/users/CedricYii/orgs","repos_url":"https://api.github.com/users/CedricYii/repos","events_url":"https://api.github.com/users/CedricYii/events{/privacy}","received_events_url":"https://api.github.com/users/CedricYii/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Is bugfix?    | no\r\n| New feature?  | yes\r\n| Breaks BC?    | no\r\n| Tests pass?   | yes\r\n| Fixed issues  | #7263, #10883 \r\n\r\nThe `@alias` placeholder enables to address dynamicaly the alias of the current table name in an active query or in a relation (without knowing it in advance).\r\n\r\nExample:\r\n````php\r\nclass Order {\r\n...\r\n  public static function find()\r\n  {\r\n    return parent::find()->orderBy( '@alias.id' );\r\n  }\r\n\r\n  //relation with table COMPANY\r\n  public function getCustomer()\r\n  {\r\n    return $this->hasOne( Company::className(), ['id' => 'customerid'] )\r\n                ->andOnCondition( [ '@alias.type' => 'customer' ] );\r\n  }\r\n...\r\n}\r\n````\r\n\r\nThen\r\n````php\r\n$orders = Order::find()->alias('o');\r\n````\r\nBuild the query:\r\n````sql\r\nselect * from order o order by o.id\r\n````\r\n\r\nAnd\r\n````php\r\n$orders = Order::find()->alias('o')->joinWith('customer c');\r\n````\r\nBuild the query:\r\n````sql\r\nselect o.* from order o \r\nleft join company c on c.id = o.customerid and c.type = 'customer'\r\norder by o.id\r\n````","created_at":"2016-05-27T10:21:20Z","updated_at":"2016-06-07T08:27:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0de784448f691431d7e3f362e49a23fbbff8f98","assignee":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/9","html_url":"https://github.com/yiisoft/yii2/milestones/2.0.x","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/9/labels","id":831720,"number":9,"title":"2.0.x","description":"","creator":{"login":"cebe","id":189796,"avatar_url":"https://avatars.githubusercontent.com/u/189796?v=3","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"open_issues":409,"closed_issues":1,"state":"open","created_at":"2014-10-19T13:49:45Z","updated_at":"2016-06-06T22:36:46Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/yiisoft/yii2/pulls/11646/commits","review_comments_url":"https://api.github.com/repos/yiisoft/yii2/pulls/11646/comments","review_comment_url":"https://api.github.com/repos/yiisoft/yii2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/11646/comments","statuses_url":"https://api.github.com/repos/yiisoft/yii2/statuses/5c3f7d158852d49a2b1ca0566a474d5527287790","head":{"label":"CedricYii:feature/aliasDynamic","ref":"feature/aliasDynamic","sha":"5c3f7d158852d49a2b1ca0566a474d5527287790","user":{"login":"CedricYii","id":14201156,"avatar_url":"https://avatars.githubusercontent.com/u/14201156?v=3","gravatar_id":"","url":"https://api.github.com/users/CedricYii","html_url":"https://github.com/CedricYii","followers_url":"https://api.github.com/users/CedricYii/followers","following_url":"https://api.github.com/users/CedricYii/following{/other_user}","gists_url":"https://api.github.com/users/CedricYii/gists{/gist_id}","starred_url":"https://api.github.com/users/CedricYii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CedricYii/subscriptions","organizations_url":"https://api.github.com/users/CedricYii/orgs","repos_url":"https://api.github.com/users/CedricYii/repos","events_url":"https://api.github.com/users/CedricYii/events{/privacy}","received_events_url":"https://api.github.com/users/CedricYii/received_events","type":"User","site_admin":false},"repo":{"id":50099480,"name":"yii2","full_name":"CedricYii/yii2","owner":{"login":"CedricYii","id":14201156,"avatar_url":"https://avatars.githubusercontent.com/u/14201156?v=3","gravatar_id":"","url":"https://api.github.com/users/CedricYii","html_url":"https://github.com/CedricYii","followers_url":"https://api.github.com/users/CedricYii/followers","following_url":"https://api.github.com/users/CedricYii/following{/other_user}","gists_url":"https://api.github.com/users/CedricYii/gists{/gist_id}","starred_url":"https://api.github.com/users/CedricYii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CedricYii/subscriptions","organizations_url":"https://api.github.com/users/CedricYii/orgs","repos_url":"https://api.github.com/users/CedricYii/repos","events_url":"https://api.github.com/users/CedricYii/events{/privacy}","received_events_url":"https://api.github.com/users/CedricYii/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/CedricYii/yii2","description":"Yii 2 framework main development repo","fork":true,"url":"https://api.github.com/repos/CedricYii/yii2","forks_url":"https://api.github.com/repos/CedricYii/yii2/forks","keys_url":"https://api.github.com/repos/CedricYii/yii2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CedricYii/yii2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CedricYii/yii2/teams","hooks_url":"https://api.github.com/repos/CedricYii/yii2/hooks","issue_events_url":"https://api.github.com/repos/CedricYii/yii2/issues/events{/number}","events_url":"https://api.github.com/repos/CedricYii/yii2/events","assignees_url":"https://api.github.com/repos/CedricYii/yii2/assignees{/user}","branches_url":"https://api.github.com/repos/CedricYii/yii2/branches{/branch}","tags_url":"https://api.github.com/repos/CedricYii/yii2/tags","blobs_url":"https://api.github.com/repos/CedricYii/yii2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CedricYii/yii2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CedricYii/yii2/git/refs{/sha}","trees_url":"https://api.github.com/repos/CedricYii/yii2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CedricYii/yii2/statuses/{sha}","languages_url":"https://api.github.com/repos/CedricYii/yii2/languages","stargazers_url":"https://api.github.com/repos/CedricYii/yii2/stargazers","contributors_url":"https://api.github.com/repos/CedricYii/yii2/contributors","subscribers_url":"https://api.github.com/repos/CedricYii/yii2/subscribers","subscription_url":"https://api.github.com/repos/CedricYii/yii2/subscription","commits_url":"https://api.github.com/repos/CedricYii/yii2/commits{/sha}","git_commits_url":"https://api.github.com/repos/CedricYii/yii2/git/commits{/sha}","comments_url":"https://api.github.com/repos/CedricYii/yii2/comments{/number}","issue_comment_url":"https://api.github.com/repos/CedricYii/yii2/issues/comments{/number}","contents_url":"https://api.github.com/repos/CedricYii/yii2/contents/{+path}","compare_url":"https://api.github.com/repos/CedricYii/yii2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CedricYii/yii2/merges","archive_url":"https://api.github.com/repos/CedricYii/yii2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CedricYii/yii2/downloads","issues_url":"https://api.github.com/repos/CedricYii/yii2/issues{/number}","pulls_url":"https://api.github.com/repos/CedricYii/yii2/pulls{/number}","milestones_url":"https://api.github.com/repos/CedricYii/yii2/milestones{/number}","notifications_url":"https://api.github.com/repos/CedricYii/yii2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CedricYii/yii2/labels{/name}","releases_url":"https://api.github.com/repos/CedricYii/yii2/releases{/id}","deployments_url":"https://api.github.com/repos/CedricYii/yii2/deployments","created_at":"2016-01-21T10:15:51Z","updated_at":"2016-01-21T10:15:55Z","pushed_at":"2016-06-06T15:54:43Z","git_url":"git://github.com/CedricYii/yii2.git","ssh_url":"git@github.com:CedricYii/yii2.git","clone_url":"https://github.com/CedricYii/yii2.git","svn_url":"https://github.com/CedricYii/yii2","homepage":"http://www.yiiframework.com","size":36549,"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":"42db3687cb4fff2bef23284463185384cab13b7c","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}","deployments_url":"https://api.github.com/repos/yiisoft/yii2/deployments","created_at":"2012-02-13T15:32:36Z","updated_at":"2016-06-07T06:55:25Z","pushed_at":"2016-06-07T08:26:07Z","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":56674,"stargazers_count":8197,"watchers_count":8197,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4791,"mirror_url":null,"open_issues_count":1033,"forks":4791,"open_issues":1033,"watchers":8197,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/11646"},"html":{"href":"https://github.com/yiisoft/yii2/pull/11646"},"issue":{"href":"https://api.github.com/repos/yiisoft/yii2/issues/11646"},"comments":{"href":"https://api.github.com/repos/yiisoft/yii2/issues/11646/comments"},"review_comments":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/11646/comments"},"review_comment":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yiisoft/yii2/pulls/11646/commits"},"statuses":{"href":"https://api.github.com/repos/yiisoft/yii2/statuses/5c3f7d158852d49a2b1ca0566a474d5527287790"}}}}
{"actor":{"display_login":"CedricYii"}}