{"id":2843,"date":"2013-04-08T15:13:14","date_gmt":"2013-04-08T06:13:14","guid":{"rendered":"http:\/\/blog.bitmeister.jp\/?p=2843"},"modified":"2013-08-22T13:29:24","modified_gmt":"2013-08-22T04:29:24","slug":"cakephp2%e3%83%a2%e3%83%87%e3%83%ab%e3%81%ae%e3%83%87%e3%83%95%e3%82%a9%e3%83%ab%e3%83%88%e3%82%aa%e3%83%bc%e3%83%80%e3%83%bc%e3%81%af%e3%82%a2%e3%82%bd%e3%82%b7%e3%82%a8%e3%83%bc%e3%82%b7%e3%83%a7","status":"publish","type":"post","link":"https:\/\/blog.bitmeister.jp\/?p=2843","title":{"rendered":"[CakePHP2] \u30e2\u30c7\u30eb\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30aa\u30fc\u30c0\u30fc\u306f\u30a2\u30bd\u30b7\u30a8\u30fc\u30b7\u30e7\u30f3\u6642\u306b\u306f\u52b9\u304b\u306a\u3044"},"content":{"rendered":"<p>\u30a2\u30bd\u30b7\u30a8\u30fc\u30b7\u30e7\u30f3\u6642\u306e\u4e0b\u4f4d\u30e2\u30c7\u30eb\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u30aa\u30fc\u30c0\u30fc\u3092\u8a2d\u5b9a\u3057\u3066\u3082\u53cd\u6620\u3055\u308c\u306a\u3044\u306e\u3067\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>DB\u306e\u69cb\u6210\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<p>&#8212;&#8211;<\/p>\n<p>users\u30c6\u30fc\u30d6\u30eb<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\u30ab\u30e9\u30e0\u540d<\/td>\n<td>\u30c7\u30fc\u30bf\u578b<\/td>\n<td>\u5916\u90e8\u30ad\u30fc<\/td>\n<\/tr>\n<tr>\n<td>id<\/td>\n<td>unsigned int<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>name<\/td>\n<td>varchar(255)<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>comments\u30c6\u30fc\u30d6\u30eb<\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\u30ab\u30e9\u30e0\u540d<\/td>\n<td>\u30c7\u30fc\u30bf\u578b<\/td>\n<td>\u5916\u90e8\u30ad\u30fc<\/td>\n<\/tr>\n<tr>\n<td>id<\/td>\n<td>unsigned int<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>user_id<\/td>\n<td>unsigned int<\/td>\n<td>users.id<\/td>\n<\/tr>\n<tr>\n<td>comment<\/td>\n<td>text<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>order<\/td>\n<td>unsigned int<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#8212;&#8211;<\/p>\n<p>Comment\u30e2\u30c7\u30eb\u3067<\/p>\n<pre><textarea class=\"php\" name=\"code\">public $order = \"Comment.order ASC\";\r\n<\/textarea><\/pre>\n<p>\u306e\u3088\u3046\u306b\u6307\u5b9a\u3059\u308b\u3068\u3001<\/p>\n<pre><textarea class=\"php\" name=\"code\">$this-&gt;Comment-&gt;find('all');\r\n<\/textarea><\/pre>\n<p>\u3067Comment.order\u306e\u6607\u9806\u3067\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001User\u30e2\u30c7\u30eb\u306b<\/p>\n<pre><textarea class=\"php\" name=\"code\">\tpublic $hasMany = array(\r\n\t\t'Comment' =&gt; array(\r\n\t\t\t'className' =&gt; 'Comment',\r\n\t\t\t'foreignKey' =&gt; 'user_id',\r\n\t\t)\r\n\t);\r\n<\/textarea><\/pre>\n<p>\u306e\u3088\u3046\u306b\u30a2\u30bd\u30b7\u30a8\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u3066\u3001<\/p>\n<pre><textarea class=\"php\" name=\"code\">$this-&gt;User-&gt;find('first');\r\n<\/textarea><\/pre>\n<p>\u3092\u3057\u3066\u3082Comment.order\u306e\u6607\u9806\u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u30a2\u30bd\u30b7\u30a8\u30fc\u30b7\u30e7\u30f3\u306e\u4e0b\u4f4d\u30e2\u30c7\u30eb\u3067\u30aa\u30fc\u30c0\u30fc\u3092\u8a2d\u5b9a\u3059\u308b\u306b\u306f<br \/>\nUser\u30e2\u30c7\u30eb\u306b<\/p>\n<pre><textarea class=\"php\" name=\"code\">\tpublic $hasMany = array(\r\n\t\t'Comment' =&gt; array(\r\n\t\t\t'className' =&gt; 'Comment',\r\n\t\t\t'foreignKey' =&gt; 'user_id',\r\n\t\t\t'order' =&gt; 'Comment.order ASC',\r\n\t\t)\r\n\t);\r\n<\/textarea><\/pre>\n<p>\u306e\u3088\u3046\u306b\u30aa\u30fc\u30c0\u30fc\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f55\u3082\u6307\u5b9a\u3057\u306a\u3051\u308c\u3070Comment\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30aa\u30fc\u30c0\u30fc\u304c\u6709\u52b9\u306b\u306a\u3089\u306a\u3044\u304b\u306a\u30fc\u3068\u3044\u3046\u6de1\u3044\u671f\u5f85\u3092\u3057\u3066\u3044\u305f\u3093\u3067\u3059\u304c\u30c0\u30e1\u3067\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a2\u30bd\u30b7\u30a8\u30fc\u30b7\u30e7\u30f3\u6642\u306e\u4e0b\u4f4d\u30e2\u30c7\u30eb\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u30aa\u30fc\u30c0\u30fc\u3092\u8a2d\u5b9a\u3057\u3066\u3082\u53cd\u6620\u3055\u308c\u306a\u3044\u306e\u3067\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[117],"class_list":["post-2843","post","type-post","status-publish","format-standard","hentry","category-tech","tag-cakephp"],"_links":{"self":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/2843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2843"}],"version-history":[{"count":33,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/2843\/revisions"}],"predecessor-version":[{"id":3054,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=\/wp\/v2\/posts\/2843\/revisions\/3054"}],"wp:attachment":[{"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bitmeister.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}