{"action":"created","comment":{"url":"https://api.github.com/repos/dgongon/g-hub/pulls/comments/41486370","id":41486370,"diff_hunk":"@@ -25,16 +26,144 @@ public static function get($id)\n             throw new RecordNotFoundException('no record found');\n         }\n         \n+        $row['is_followed'] = $is_followed;\n+\n         return new self($row);\n     }\n \n+    public static function getAll($offset, $limit) \n+    { \n+        $db = DB::conn();\n+        $rows = $db->rows(\"SELECT * \n+            FROM thread \n+            LIMIT {$offset}, {$limit}\");\n+\n+        /*if (!$rows) {    \n+            throw new RecordNotFoundException('no record found');\n+        }*/\n+\n+        $threads = array();\n+    \n+        foreach ($rows as $row) {\n+            $threads[] = new self($row);\n+            \n+        }\n+\n+        return $threads;\n+    }\n+\n+    public static function getByCategory($keyword)\n+    {\n+        $db = DB::conn();\n+        $rows = $db->rows(\"SELECT * \n+            FROM thread \n+            WHERE category = ?\", \n+            array($keyword));\n+\n+        /*if (!$rows) {    \n+            throw new RecordNotFoundException('no record found');\n+        }*/\n+\n+        $results = array();\n+\n+        foreach ($rows as $row) {\n+            $results[] = new self($row);\n+        }\n+\n+        return $results;\n+    }\n+\n+    public static function getByUsername($keyword)\n+    {\n+        $db = DB::conn();\n+\n+        $user_id = $db->row('SELECT id \n+            FROM user\n+            WHERE username = ?',\n+            array($keyword));\n+\n+        $rows = $db->rows('SELECT * \n+            FROM thread \n+            WHERE user_id = ?', \n+            array($user_id['id']));\n+\n+        /*if (!$rows) {    \n+            throw new RecordNotFoundException('no record found');\n+        }*/\n+\n+        $results = array();\n+\n+        foreach ($rows as $row) {\n+            $results[] = new self($row);\n+        }\n+        return $results;\n+    }\n+\n+    public static function getByTitle($keyword)\n+    {\n+        $results = array();\n+\n+        $db = DB::conn();\n+        $rows = $db->rows('SELECT * ","path":"app/models/thread.php","position":94,"original_position":94,"commit_id":"d7f20c8169708790d9594d3b27080069aa468217","original_commit_id":"d7f20c8169708790d9594d3b27080069aa468217","user":{"login":"cheyluna","id":1736629,"avatar_url":"https://avatars.githubusercontent.com/u/1736629?v=3","gravatar_id":"","url":"https://api.github.com/users/cheyluna","html_url":"https://github.com/cheyluna","followers_url":"https://api.github.com/users/cheyluna/followers","following_url":"https://api.github.com/users/cheyluna/following{/other_user}","gists_url":"https://api.github.com/users/cheyluna/gists{/gist_id}","starred_url":"https://api.github.com/users/cheyluna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cheyluna/subscriptions","organizations_url":"https://api.github.com/users/cheyluna/orgs","repos_url":"https://api.github.com/users/cheyluna/repos","events_url":"https://api.github.com/users/cheyluna/events{/privacy}","received_events_url":"https://api.github.com/users/cheyluna/received_events","type":"User","site_admin":false},"body":"Try to substitute your raw queries with CakePHP's built-in methods.\r\n```php\r\n$rows = $this->Thread->find('all');\r\n```","created_at":"2015-10-08T08:12:14Z","updated_at":"2015-10-08T08:12:14Z","html_url":"https://github.com/dgongon/g-hub/pull/2#discussion_r41486370","pull_request_url":"https://api.github.com/repos/dgongon/g-hub/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/dgongon/g-hub/pulls/comments/41486370"},"html":{"href":"https://github.com/dgongon/g-hub/pull/2#discussion_r41486370"},"pull_request":{"href":"https://api.github.com/repos/dgongon/g-hub/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/dgongon/g-hub/pulls/2","id":46738203,"html_url":"https://github.com/dgongon/g-hub/pull/2","diff_url":"https://github.com/dgongon/g-hub/pull/2.diff","patch_url":"https://github.com/dgongon/g-hub/pull/2.patch","issue_url":"https://api.github.com/repos/dgongon/g-hub/issues/2","number":2,"state":"open","locked":false,"title":"PR for dev_1.1","user":{"login":"dgongon","id":13651463,"avatar_url":"https://avatars.githubusercontent.com/u/13651463?v=3","gravatar_id":"","url":"https://api.github.com/users/dgongon","html_url":"https://github.com/dgongon","followers_url":"https://api.github.com/users/dgongon/followers","following_url":"https://api.github.com/users/dgongon/following{/other_user}","gists_url":"https://api.github.com/users/dgongon/gists{/gist_id}","starred_url":"https://api.github.com/users/dgongon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgongon/subscriptions","organizations_url":"https://api.github.com/users/dgongon/orgs","repos_url":"https://api.github.com/users/dgongon/repos","events_url":"https://api.github.com/users/dgongon/events{/privacy}","received_events_url":"https://api.github.com/users/dgongon/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-05T01:16:40Z","updated_at":"2015-10-08T08:12:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fc4e25df2f68682da9581ebd7ca54ea93c69a0e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dgongon/g-hub/pulls/2/commits","review_comments_url":"https://api.github.com/repos/dgongon/g-hub/pulls/2/comments","review_comment_url":"https://api.github.com/repos/dgongon/g-hub/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dgongon/g-hub/issues/2/comments","statuses_url":"https://api.github.com/repos/dgongon/g-hub/statuses/d7f20c8169708790d9594d3b27080069aa468217","head":{"label":"dgongon:dev_1.1","ref":"dev_1.1","sha":"d7f20c8169708790d9594d3b27080069aa468217","user":{"login":"dgongon","id":13651463,"avatar_url":"https://avatars.githubusercontent.com/u/13651463?v=3","gravatar_id":"","url":"https://api.github.com/users/dgongon","html_url":"https://github.com/dgongon","followers_url":"https://api.github.com/users/dgongon/followers","following_url":"https://api.github.com/users/dgongon/following{/other_user}","gists_url":"https://api.github.com/users/dgongon/gists{/gist_id}","starred_url":"https://api.github.com/users/dgongon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgongon/subscriptions","organizations_url":"https://api.github.com/users/dgongon/orgs","repos_url":"https://api.github.com/users/dgongon/repos","events_url":"https://api.github.com/users/dgongon/events{/privacy}","received_events_url":"https://api.github.com/users/dgongon/received_events","type":"User","site_admin":false},"repo":{"id":42223465,"name":"g-hub","full_name":"dgongon/g-hub","owner":{"login":"dgongon","id":13651463,"avatar_url":"https://avatars.githubusercontent.com/u/13651463?v=3","gravatar_id":"","url":"https://api.github.com/users/dgongon","html_url":"https://github.com/dgongon","followers_url":"https://api.github.com/users/dgongon/followers","following_url":"https://api.github.com/users/dgongon/following{/other_user}","gists_url":"https://api.github.com/users/dgongon/gists{/gist_id}","starred_url":"https://api.github.com/users/dgongon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgongon/subscriptions","organizations_url":"https://api.github.com/users/dgongon/orgs","repos_url":"https://api.github.com/users/dgongon/repos","events_url":"https://api.github.com/users/dgongon/events{/privacy}","received_events_url":"https://api.github.com/users/dgongon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgongon/g-hub","description":"","fork":false,"url":"https://api.github.com/repos/dgongon/g-hub","forks_url":"https://api.github.com/repos/dgongon/g-hub/forks","keys_url":"https://api.github.com/repos/dgongon/g-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgongon/g-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgongon/g-hub/teams","hooks_url":"https://api.github.com/repos/dgongon/g-hub/hooks","issue_events_url":"https://api.github.com/repos/dgongon/g-hub/issues/events{/number}","events_url":"https://api.github.com/repos/dgongon/g-hub/events","assignees_url":"https://api.github.com/repos/dgongon/g-hub/assignees{/user}","branches_url":"https://api.github.com/repos/dgongon/g-hub/branches{/branch}","tags_url":"https://api.github.com/repos/dgongon/g-hub/tags","blobs_url":"https://api.github.com/repos/dgongon/g-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgongon/g-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgongon/g-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgongon/g-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgongon/g-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/dgongon/g-hub/languages","stargazers_url":"https://api.github.com/repos/dgongon/g-hub/stargazers","contributors_url":"https://api.github.com/repos/dgongon/g-hub/contributors","subscribers_url":"https://api.github.com/repos/dgongon/g-hub/subscribers","subscription_url":"https://api.github.com/repos/dgongon/g-hub/subscription","commits_url":"https://api.github.com/repos/dgongon/g-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgongon/g-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgongon/g-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgongon/g-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgongon/g-hub/contents/{+path}","compare_url":"https://api.github.com/repos/dgongon/g-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgongon/g-hub/merges","archive_url":"https://api.github.com/repos/dgongon/g-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgongon/g-hub/downloads","issues_url":"https://api.github.com/repos/dgongon/g-hub/issues{/number}","pulls_url":"https://api.github.com/repos/dgongon/g-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/dgongon/g-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/dgongon/g-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgongon/g-hub/labels{/name}","releases_url":"https://api.github.com/repos/dgongon/g-hub/releases{/id}","created_at":"2015-09-10T05:11:18Z","updated_at":"2015-09-24T04:25:36Z","pushed_at":"2015-10-08T07:33:49Z","git_url":"git://github.com/dgongon/g-hub.git","ssh_url":"git@github.com:dgongon/g-hub.git","clone_url":"https://github.com/dgongon/g-hub.git","svn_url":"https://github.com/dgongon/g-hub","homepage":null,"size":568,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"dev_1.1"}},"base":{"label":"dgongon:master","ref":"master","sha":"440ad8dae2ac06d0d5ba69cfeb2953d9f600d8f6","user":{"login":"dgongon","id":13651463,"avatar_url":"https://avatars.githubusercontent.com/u/13651463?v=3","gravatar_id":"","url":"https://api.github.com/users/dgongon","html_url":"https://github.com/dgongon","followers_url":"https://api.github.com/users/dgongon/followers","following_url":"https://api.github.com/users/dgongon/following{/other_user}","gists_url":"https://api.github.com/users/dgongon/gists{/gist_id}","starred_url":"https://api.github.com/users/dgongon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgongon/subscriptions","organizations_url":"https://api.github.com/users/dgongon/orgs","repos_url":"https://api.github.com/users/dgongon/repos","events_url":"https://api.github.com/users/dgongon/events{/privacy}","received_events_url":"https://api.github.com/users/dgongon/received_events","type":"User","site_admin":false},"repo":{"id":42223465,"name":"g-hub","full_name":"dgongon/g-hub","owner":{"login":"dgongon","id":13651463,"avatar_url":"https://avatars.githubusercontent.com/u/13651463?v=3","gravatar_id":"","url":"https://api.github.com/users/dgongon","html_url":"https://github.com/dgongon","followers_url":"https://api.github.com/users/dgongon/followers","following_url":"https://api.github.com/users/dgongon/following{/other_user}","gists_url":"https://api.github.com/users/dgongon/gists{/gist_id}","starred_url":"https://api.github.com/users/dgongon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgongon/subscriptions","organizations_url":"https://api.github.com/users/dgongon/orgs","repos_url":"https://api.github.com/users/dgongon/repos","events_url":"https://api.github.com/users/dgongon/events{/privacy}","received_events_url":"https://api.github.com/users/dgongon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgongon/g-hub","description":"","fork":false,"url":"https://api.github.com/repos/dgongon/g-hub","forks_url":"https://api.github.com/repos/dgongon/g-hub/forks","keys_url":"https://api.github.com/repos/dgongon/g-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgongon/g-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgongon/g-hub/teams","hooks_url":"https://api.github.com/repos/dgongon/g-hub/hooks","issue_events_url":"https://api.github.com/repos/dgongon/g-hub/issues/events{/number}","events_url":"https://api.github.com/repos/dgongon/g-hub/events","assignees_url":"https://api.github.com/repos/dgongon/g-hub/assignees{/user}","branches_url":"https://api.github.com/repos/dgongon/g-hub/branches{/branch}","tags_url":"https://api.github.com/repos/dgongon/g-hub/tags","blobs_url":"https://api.github.com/repos/dgongon/g-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgongon/g-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgongon/g-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgongon/g-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgongon/g-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/dgongon/g-hub/languages","stargazers_url":"https://api.github.com/repos/dgongon/g-hub/stargazers","contributors_url":"https://api.github.com/repos/dgongon/g-hub/contributors","subscribers_url":"https://api.github.com/repos/dgongon/g-hub/subscribers","subscription_url":"https://api.github.com/repos/dgongon/g-hub/subscription","commits_url":"https://api.github.com/repos/dgongon/g-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgongon/g-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgongon/g-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgongon/g-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgongon/g-hub/contents/{+path}","compare_url":"https://api.github.com/repos/dgongon/g-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgongon/g-hub/merges","archive_url":"https://api.github.com/repos/dgongon/g-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgongon/g-hub/downloads","issues_url":"https://api.github.com/repos/dgongon/g-hub/issues{/number}","pulls_url":"https://api.github.com/repos/dgongon/g-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/dgongon/g-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/dgongon/g-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgongon/g-hub/labels{/name}","releases_url":"https://api.github.com/repos/dgongon/g-hub/releases{/id}","created_at":"2015-09-10T05:11:18Z","updated_at":"2015-09-24T04:25:36Z","pushed_at":"2015-10-08T07:33:49Z","git_url":"git://github.com/dgongon/g-hub.git","ssh_url":"git@github.com:dgongon/g-hub.git","clone_url":"https://github.com/dgongon/g-hub.git","svn_url":"https://github.com/dgongon/g-hub","homepage":null,"size":568,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"dev_1.1"}},"_links":{"self":{"href":"https://api.github.com/repos/dgongon/g-hub/pulls/2"},"html":{"href":"https://github.com/dgongon/g-hub/pull/2"},"issue":{"href":"https://api.github.com/repos/dgongon/g-hub/issues/2"},"comments":{"href":"https://api.github.com/repos/dgongon/g-hub/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/dgongon/g-hub/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/dgongon/g-hub/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dgongon/g-hub/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/dgongon/g-hub/statuses/d7f20c8169708790d9594d3b27080069aa468217"}}}}