{"action":"reopened","number":22,"pull_request":{"url":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/22","id":67474292,"html_url":"https://github.com/machuga/php-activerecord-spark/pull/22","diff_url":"https://github.com/machuga/php-activerecord-spark/pull/22.diff","patch_url":"https://github.com/machuga/php-activerecord-spark/pull/22.patch","issue_url":"https://api.github.com/repos/machuga/php-activerecord-spark/issues/22","number":22,"state":"open","locked":false,"title":"Update Relationship.php","user":{"login":"github-ondev","id":9050757,"avatar_url":"https://avatars.githubusercontent.com/u/9050757?v=3","gravatar_id":"","url":"https://api.github.com/users/github-ondev","html_url":"https://github.com/github-ondev","followers_url":"https://api.github.com/users/github-ondev/followers","following_url":"https://api.github.com/users/github-ondev/following{/other_user}","gists_url":"https://api.github.com/users/github-ondev/gists{/gist_id}","starred_url":"https://api.github.com/users/github-ondev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github-ondev/subscriptions","organizations_url":"https://api.github.com/users/github-ondev/orgs","repos_url":"https://api.github.com/users/github-ondev/repos","events_url":"https://api.github.com/users/github-ondev/events{/privacy}","received_events_url":"https://api.github.com/users/github-ondev/received_events","type":"User","site_admin":false},"body":"In a \"has many through\" relationship, the foreign key is obtained from the option \"foreign key\" of the relationship in the related model tha have the same name of the \"through\" option.\r\nES:\r\nTable A=(id, x), PK=id\r\nTable B=(id,y), PD=id\r\nTable C=(id,idA,idB) PK=id FK=(idA->A.id, idB->B.id)\r\n\r\nclass A extends ActiveRecord\\Model {\r\n\tstatic $has_many = array(\r\n\t\tarray('aliasB',\t'class_name' => 'B', 'through' => 'aliasC', 'foreign_key' => 'idA')\r\n\t);\r\n}\r\n\r\nclass B extends ActiveRecord\\Model{\r\n\tstatic $has_many = array(\r\n\t\tarray('aliasC', 'class_name' => 'C', 'foreign_key' => 'idB'),\r\n\t);\t\r\n}\r\n\r\nclass C extends ActiveRecord\\Model {\r\n\tstatic $belongs_to = array(\r\n\t\tarray('aliasA', 'class_name' => 'A', 'foreign_key' => 'idA'),\r\n\t\tarray('aliasB',\t'class_name' => 'B', 'foreign_key' => 'idB')\r\n\t);\r\n}\r\n\r\n\"A\" has many \"B\" through \"C\": the foreign key between \"B\" and \"C\" is the foreing key of the \"has many\" array of \"C\" witch is named like the \"through\" option of che \"has many through\" relationship of \"A\".","created_at":"2016-04-22T08:13:10Z","updated_at":"2016-04-22T08:24:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4620c6bf372c042f021052f34066c2299e46b8cd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/22/commits","review_comments_url":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/22/comments","review_comment_url":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/machuga/php-activerecord-spark/issues/22/comments","statuses_url":"https://api.github.com/repos/machuga/php-activerecord-spark/statuses/1035a9ed3c909b4eaca12f1b6be1f462e7cb75aa","head":{"label":"github-ondev:master","ref":"master","sha":"1035a9ed3c909b4eaca12f1b6be1f462e7cb75aa","user":{"login":"github-ondev","id":9050757,"avatar_url":"https://avatars.githubusercontent.com/u/9050757?v=3","gravatar_id":"","url":"https://api.github.com/users/github-ondev","html_url":"https://github.com/github-ondev","followers_url":"https://api.github.com/users/github-ondev/followers","following_url":"https://api.github.com/users/github-ondev/following{/other_user}","gists_url":"https://api.github.com/users/github-ondev/gists{/gist_id}","starred_url":"https://api.github.com/users/github-ondev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github-ondev/subscriptions","organizations_url":"https://api.github.com/users/github-ondev/orgs","repos_url":"https://api.github.com/users/github-ondev/repos","events_url":"https://api.github.com/users/github-ondev/events{/privacy}","received_events_url":"https://api.github.com/users/github-ondev/received_events","type":"User","site_admin":false},"repo":{"id":56836035,"name":"php-activerecord-spark","full_name":"github-ondev/php-activerecord-spark","owner":{"login":"github-ondev","id":9050757,"avatar_url":"https://avatars.githubusercontent.com/u/9050757?v=3","gravatar_id":"","url":"https://api.github.com/users/github-ondev","html_url":"https://github.com/github-ondev","followers_url":"https://api.github.com/users/github-ondev/followers","following_url":"https://api.github.com/users/github-ondev/following{/other_user}","gists_url":"https://api.github.com/users/github-ondev/gists{/gist_id}","starred_url":"https://api.github.com/users/github-ondev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github-ondev/subscriptions","organizations_url":"https://api.github.com/users/github-ondev/orgs","repos_url":"https://api.github.com/users/github-ondev/repos","events_url":"https://api.github.com/users/github-ondev/events{/privacy}","received_events_url":"https://api.github.com/users/github-ondev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/github-ondev/php-activerecord-spark","description":"CodeIgniter 2.0+ Spark to integrate PHPActiveRecord into CodeIgniter","fork":true,"url":"https://api.github.com/repos/github-ondev/php-activerecord-spark","forks_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/forks","keys_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/teams","hooks_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/hooks","issue_events_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/issues/events{/number}","events_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/events","assignees_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/assignees{/user}","branches_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/branches{/branch}","tags_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/tags","blobs_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/statuses/{sha}","languages_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/languages","stargazers_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/stargazers","contributors_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/contributors","subscribers_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/subscribers","subscription_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/subscription","commits_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/contents/{+path}","compare_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/merges","archive_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/downloads","issues_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/issues{/number}","pulls_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/pulls{/number}","milestones_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/milestones{/number}","notifications_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/labels{/name}","releases_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/releases{/id}","deployments_url":"https://api.github.com/repos/github-ondev/php-activerecord-spark/deployments","created_at":"2016-04-22T07:36:35Z","updated_at":"2016-04-22T07:36:36Z","pushed_at":"2016-04-22T08:10:27Z","git_url":"git://github.com/github-ondev/php-activerecord-spark.git","ssh_url":"git@github.com:github-ondev/php-activerecord-spark.git","clone_url":"https://github.com/github-ondev/php-activerecord-spark.git","svn_url":"https://github.com/github-ondev/php-activerecord-spark","homepage":"","size":137,"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":"machuga:master","ref":"master","sha":"539d27f199bc332a03890b9cc512d0cda84ced21","user":{"login":"machuga","id":182000,"avatar_url":"https://avatars.githubusercontent.com/u/182000?v=3","gravatar_id":"","url":"https://api.github.com/users/machuga","html_url":"https://github.com/machuga","followers_url":"https://api.github.com/users/machuga/followers","following_url":"https://api.github.com/users/machuga/following{/other_user}","gists_url":"https://api.github.com/users/machuga/gists{/gist_id}","starred_url":"https://api.github.com/users/machuga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/machuga/subscriptions","organizations_url":"https://api.github.com/users/machuga/orgs","repos_url":"https://api.github.com/users/machuga/repos","events_url":"https://api.github.com/users/machuga/events{/privacy}","received_events_url":"https://api.github.com/users/machuga/received_events","type":"User","site_admin":false},"repo":{"id":1651014,"name":"php-activerecord-spark","full_name":"machuga/php-activerecord-spark","owner":{"login":"machuga","id":182000,"avatar_url":"https://avatars.githubusercontent.com/u/182000?v=3","gravatar_id":"","url":"https://api.github.com/users/machuga","html_url":"https://github.com/machuga","followers_url":"https://api.github.com/users/machuga/followers","following_url":"https://api.github.com/users/machuga/following{/other_user}","gists_url":"https://api.github.com/users/machuga/gists{/gist_id}","starred_url":"https://api.github.com/users/machuga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/machuga/subscriptions","organizations_url":"https://api.github.com/users/machuga/orgs","repos_url":"https://api.github.com/users/machuga/repos","events_url":"https://api.github.com/users/machuga/events{/privacy}","received_events_url":"https://api.github.com/users/machuga/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/machuga/php-activerecord-spark","description":"CodeIgniter 2.0+ Spark to integrate PHPActiveRecord into CodeIgniter","fork":false,"url":"https://api.github.com/repos/machuga/php-activerecord-spark","forks_url":"https://api.github.com/repos/machuga/php-activerecord-spark/forks","keys_url":"https://api.github.com/repos/machuga/php-activerecord-spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/machuga/php-activerecord-spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/machuga/php-activerecord-spark/teams","hooks_url":"https://api.github.com/repos/machuga/php-activerecord-spark/hooks","issue_events_url":"https://api.github.com/repos/machuga/php-activerecord-spark/issues/events{/number}","events_url":"https://api.github.com/repos/machuga/php-activerecord-spark/events","assignees_url":"https://api.github.com/repos/machuga/php-activerecord-spark/assignees{/user}","branches_url":"https://api.github.com/repos/machuga/php-activerecord-spark/branches{/branch}","tags_url":"https://api.github.com/repos/machuga/php-activerecord-spark/tags","blobs_url":"https://api.github.com/repos/machuga/php-activerecord-spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/machuga/php-activerecord-spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/machuga/php-activerecord-spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/machuga/php-activerecord-spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/machuga/php-activerecord-spark/statuses/{sha}","languages_url":"https://api.github.com/repos/machuga/php-activerecord-spark/languages","stargazers_url":"https://api.github.com/repos/machuga/php-activerecord-spark/stargazers","contributors_url":"https://api.github.com/repos/machuga/php-activerecord-spark/contributors","subscribers_url":"https://api.github.com/repos/machuga/php-activerecord-spark/subscribers","subscription_url":"https://api.github.com/repos/machuga/php-activerecord-spark/subscription","commits_url":"https://api.github.com/repos/machuga/php-activerecord-spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/machuga/php-activerecord-spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/machuga/php-activerecord-spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/machuga/php-activerecord-spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/machuga/php-activerecord-spark/contents/{+path}","compare_url":"https://api.github.com/repos/machuga/php-activerecord-spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/machuga/php-activerecord-spark/merges","archive_url":"https://api.github.com/repos/machuga/php-activerecord-spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/machuga/php-activerecord-spark/downloads","issues_url":"https://api.github.com/repos/machuga/php-activerecord-spark/issues{/number}","pulls_url":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls{/number}","milestones_url":"https://api.github.com/repos/machuga/php-activerecord-spark/milestones{/number}","notifications_url":"https://api.github.com/repos/machuga/php-activerecord-spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/machuga/php-activerecord-spark/labels{/name}","releases_url":"https://api.github.com/repos/machuga/php-activerecord-spark/releases{/id}","deployments_url":"https://api.github.com/repos/machuga/php-activerecord-spark/deployments","created_at":"2011-04-22T19:12:41Z","updated_at":"2016-01-28T23:22:59Z","pushed_at":"2016-04-22T08:13:11Z","git_url":"git://github.com/machuga/php-activerecord-spark.git","ssh_url":"git@github.com:machuga/php-activerecord-spark.git","clone_url":"https://github.com/machuga/php-activerecord-spark.git","svn_url":"https://github.com/machuga/php-activerecord-spark","homepage":"","size":176,"stargazers_count":47,"watchers_count":47,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":8,"forks":16,"open_issues":8,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/22"},"html":{"href":"https://github.com/machuga/php-activerecord-spark/pull/22"},"issue":{"href":"https://api.github.com/repos/machuga/php-activerecord-spark/issues/22"},"comments":{"href":"https://api.github.com/repos/machuga/php-activerecord-spark/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/machuga/php-activerecord-spark/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/machuga/php-activerecord-spark/statuses/1035a9ed3c909b4eaca12f1b6be1f462e7cb75aa"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":1,"review_comments":0,"commits":1,"additions":10,"deletions":5,"changed_files":1}}