{"action":"opened","issue":{"url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/255","repository_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model","labels_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/255/labels{/name}","comments_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/255/comments","events_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/255/events","html_url":"https://github.com/avenirer/CodeIgniter-MY_Model/issues/255","id":249994282,"number":255,"title":"Right Join instead of Left Join","user":{"login":"ierpe","id":790992,"avatar_url":"https://avatars2.githubusercontent.com/u/790992?v=4","gravatar_id":"","url":"https://api.github.com/users/ierpe","html_url":"https://github.com/ierpe","followers_url":"https://api.github.com/users/ierpe/followers","following_url":"https://api.github.com/users/ierpe/following{/other_user}","gists_url":"https://api.github.com/users/ierpe/gists{/gist_id}","starred_url":"https://api.github.com/users/ierpe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ierpe/subscriptions","organizations_url":"https://api.github.com/users/ierpe/orgs","repos_url":"https://api.github.com/users/ierpe/repos","events_url":"https://api.github.com/users/ierpe/events{/privacy}","received_events_url":"https://api.github.com/users/ierpe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-14T10:39:53Z","updated_at":"2017-08-14T10:39:53Z","closed_at":null,"body":"Hi,\r\n\r\nI have a Role mode linked with a Subcategory model through a pivot table.\r\nIn my Role model, I have : \r\n\r\n```\r\n    $this->has_many_pivot['subcategories'] = array(\r\n        'foreign_model'=>'Subcategories_model',\r\n        'pivot_table'=>'app_menus_app_userroles',\r\n        'local_key'=>'id',\r\n        'pivot_local_key'=>'app_menu_id',\r\n        'pivot_foreign_key'=>'app_userrole_id', \r\n        'foreign_key'=>'id',\r\n        'get_relate'=>TRUE \r\n    );\r\n```\r\nThen when I call : \r\n\r\n```\r\n        $role = $this->roles_model\r\n                      ->with('subcategories')\r\n                      ->get($r->id);\r\n```\r\nI get the following result : \r\n\r\n```\r\nstdClass Object (\r\n[id] => 2\r\n[name] => Client\r\n[reference] => client\r\n[subcategories] =>\r\n)\r\n```\r\nprint_r($this->db->last_query()); returns : \r\n\r\n```\r\nSELECT `app_menus`.`id`, `app_menus_app_userroles`.`app_menu_id`\r\nFROM `app_menus`\r\nLEFT JOIN `app_menus_app_userroles` ON `app_menus`.`id` = `app_menus_app_userroles`.`app_userrole_id`\r\nLEFT JOIN `app_userroles` ON `app_menus_app_userroles`.`app_menu_id` = `app_userroles`.`id`\r\nWHERE `app_menus_app_userroles`.`app_menu_id` IN('2')\r\n\r\n```\r\nWhich also returns nothing when I run it on mysql. \r\nBut when I replace the Left Joins with Right Joins in the query, I get the expected results (there's definitely subcategories linked with this role in my db)\r\n\r\nWhat am I doing wrong here? Is my definition wrong or is there a way to force a right join instead of a left join?\r\n\r\nKind regards\r\n\r\n\r\n"}}
{"actor":{"display_login":"ierpe"}}