{"action":"created","issue":{"url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/23","labels_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/23/comments","events_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/23/events","html_url":"https://github.com/avenirer/CodeIgniter-MY_Model/issues/23","id":86292191,"number":23,"title":"error: Undefined index: id    .. ->with_*('fields:some_fields except primary key')","user":{"login":"ngangchill","id":4242225,"avatar_url":"https://avatars.githubusercontent.com/u/4242225?v=3","gravatar_id":"","url":"https://api.github.com/users/ngangchill","html_url":"https://github.com/ngangchill","followers_url":"https://api.github.com/users/ngangchill/followers","following_url":"https://api.github.com/users/ngangchill/following{/other_user}","gists_url":"https://api.github.com/users/ngangchill/gists{/gist_id}","starred_url":"https://api.github.com/users/ngangchill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngangchill/subscriptions","organizations_url":"https://api.github.com/users/ngangchill/orgs","repos_url":"https://api.github.com/users/ngangchill/repos","events_url":"https://api.github.com/users/ngangchill/events{/privacy}","received_events_url":"https://api.github.com/users/ngangchill/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-06-08T18:58:58Z","updated_at":"2015-06-10T09:21:26Z","closed_at":null,"body":"## Blog_m.php\r\n\r\n      class Blog_m extends MY_Model {\r\n\r\n    public $table = 'blog_posts'; \r\n    public $primary_key = 'postID';\r\n    //public $fillable = array();\r\n    public $protected = array('postID'); \r\n\r\n    public function __construct() {\r\n        $this->timestamps = TRUE;\r\n        $this->soft_deletes = TRUE;\r\n        $this->has_one['cats'] = array('Bcats_m','catID','catID');\r\n        $this->has_one['user'] = array('User_m','id','userID');\r\n        $this->has_many['comments'] = array('Bcomments_m', 'postID','postID');\r\n        parent::__construct();\r\n        }\r\n\r\n      }\r\n\r\n\r\n## User_m.php\r\n\r\n\r\n     class User_m extends MY_Model {\r\n    public $table = 'users'; // you MUST mention the table name\r\n    public $primary_key = 'id'; // you MUST mention the primary key\r\n      public $protected = array('id'); // ...Or you can set an array with the fields that cannot be filled by insert/update\r\n\r\n    public function __construct() {\r\n        $this->has_many['blog'] = array('Blog_m','userID','id');\r\n\t$this->has_many['comment'] = array('Bcomments_m','userID','id');\r\n        parent::__construct();\r\n        }\r\n     }\r\n\r\n# Controller:\r\n  ## 1.\r\n     $data = $this->blog_m->with_user()->get_all();       \r\n       \r\n      ### works fine\r\n \r\n## 2.\r\n\r\n      $data = $this->blog_m->with_user('fields:id')->get_all(); // id = primary key \r\n\r\n     ### works fine\r\n\r\n## 3. \r\n\r\n      $data = $this->blog_m->with_user('fields:username')->get_all();\r\n\r\n     ### shows error.\r\n\r\n    A PHP Error was encountered\r\n\r\n     Severity: Notice\r\n\r\n     Message: Undefined index: id\r\n\r\n     Filename: core/MY_Model.php\r\n\r\n     Line Number: 938\r\n\r\n     Backtrace:\r\n\r\n      File: C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC9\\data\\localweb\\sites\\blog\\application\\core\\MY_Model.php\r\nLine: 938\r\nFunction: _error_handler\r\n\r\nFile: C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC9\\data\\localweb\\sites\\blog\\application\\core\\MY_Model.php\r\n     Line: 253\r\nFunction: join_temporary_results\r\n\r\n       File: C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC9\\data\\localweb\\sites\\blog\\application\\core\\MY_Model.php\r\nLine: 792\r\n        Function: _prep_after_read\r\n\r\n       File: C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC9\\data\\localweb\\sites\\blog\\application\\controllers\\Welcome.php\r\nLine: 14\r\n       Function: get_all\r\n\r\n       File: C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC9\\data\\localweb\\sites\\blog\\index.php\r\n        Line: 292\r\n        Function: require_once\r\n"},"comment":{"url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/comments/110667086","html_url":"https://github.com/avenirer/CodeIgniter-MY_Model/issues/23#issuecomment-110667086","issue_url":"https://api.github.com/repos/avenirer/CodeIgniter-MY_Model/issues/23","id":110667086,"user":{"login":"avenirer","id":3034772,"avatar_url":"https://avatars.githubusercontent.com/u/3034772?v=3","gravatar_id":"","url":"https://api.github.com/users/avenirer","html_url":"https://github.com/avenirer","followers_url":"https://api.github.com/users/avenirer/followers","following_url":"https://api.github.com/users/avenirer/following{/other_user}","gists_url":"https://api.github.com/users/avenirer/gists{/gist_id}","starred_url":"https://api.github.com/users/avenirer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avenirer/subscriptions","organizations_url":"https://api.github.com/users/avenirer/orgs","repos_url":"https://api.github.com/users/avenirer/repos","events_url":"https://api.github.com/users/avenirer/events{/privacy}","received_events_url":"https://api.github.com/users/avenirer/received_events","type":"User","site_admin":false},"created_at":"2015-06-10T09:21:26Z","updated_at":"2015-06-10T09:21:26Z","body":"Thank you. You do a very good job. Keep doing it. I really need testers :+1: "}}