{"id":1896,"date":"2011-02-01T05:03:55","date_gmt":"2011-01-31T11:03:55","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/1896"},"modified":"2011-02-01T13:59:55","modified_gmt":"2011-02-01T04:59:55","slug":"cakephp-%e3%81%8b%e3%82%89-wordpress-%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e6%89%b1%e3%81%862-2","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/1896","title":{"rendered":"CakePHP \u304b\u3089 wordpress \u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046(2)"},"content":{"rendered":"<p>\u4eca\u5ea6\u306f\u3001wordpress \u306e\u30b3\u30e1\u30f3\u30c8\u8868\u793a<\/p>\n<p>CakePHP \u304b\u3089 wordpress \u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046 | Moonmile Solutions Blog<br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/archives\/1888\">http:\/\/www.moonmile.net\/blog\/archives\/1888<\/a><\/p>\n<p>\u306e\u3068\u3053\u308d\u3067\u8a18\u4e8b\u306e\u8868\u793a\u304c\u3067\u304d\u305f\u306e\u3067\u3001\u3053\u308c\u3092\u6d41\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a2\u30af\u30bb\u30b9\u306f http:\/\/servername\/comments\/recent \u306e\u3088\u3046\u306b\u3057\u3066\u3001\u6700\u8fd1\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u53d6\u5f97\u3002<\/p>\n<p>\u25a0\u30d3\u30e5\u30fc\u3092\u4f5c\u308b<\/p>\n<p>\u3072\u306a\u578b\u304c\u51fa\u6765\u3066\u3044\u308b\u306e\u3067\u3001\u4eca\u5ea6\u306f\u3044\u304d\u306a\u308a\u30d3\u30e5\u30fc\u3092\u4f5c\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br \/>\n\u30e2\u30c7\u30eb\u540d\u3084\u30c6\u30fc\u30d6\u30eb\u306e\u30ab\u30e9\u30e0\u540d\u306a\u3093\u304b\u306f\u60f3\u5b9a\u3067\u4f5c\u3063\u3066\u3057\u307e\u3063\u3066\u3001\u5f8c\u3067\u5408\u308f\u305b\u308b\u3063\u3066\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u306d\u3002\u30c6\u30fc\u30d6\u30eb\u4ed5\u69d8\u66f8\u304c\u3067\u304d\u3066\u3044\u308c\u3070\u3001\u3053\u308c\u3067\u5206\u696d\u304c\u3067\u304d\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;h2&gt;\u6700\u8fd1\u6295\u7a3f\u3055\u308c\u305f\u30b3\u30e1\u30f3\u30c8&lt;\/h2&gt;\r\n&lt;table&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;th&gt;comment_ID&lt;\/th&gt;\r\n\t\t&lt;th&gt;comment_post_ID&lt;\/th&gt;\r\n\t\t&lt;th&gt;comment_author&lt;\/th&gt;\r\n\t&lt;\/tr&gt;\r\n\t&lt;?php foreach($Comments as $item) : ?&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_ID&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_post_ID&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_author&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_author_url&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;post_title&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;guid&#039;]; ?&gt;\r\n\t&lt;\/tr&gt;\r\n\t&lt;?php endforeach ; ?&gt;\r\n&lt;\/table&gt;\r\n\r\n&lt;h2&gt;\u6700\u8fd1\u6295\u7a3f\u3055\u308c\u305f\u30b3\u30e1\u30f3\u30c8(\u30ea\u30f3\u30af\u7248)&lt;\/h2&gt;\r\n&lt;ul&gt;\r\n\t&lt;?php foreach($Comments as $item) : ?&gt;\r\n\t\t&lt;li&gt;\r\n\t\t\t&lt;?php if ( $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_author_url&#039;] == &#039;&#039; ) : ?&gt;\r\n\t\t\t\t&lt;?php echo $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_author&#039;]; ?&gt;\r\n\t\t\t&lt;?php else : ?&gt;\r\n\t\t\t\t&lt;a href=&amp;quot;&lt;?php echo $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_author_url&#039;]; ?&gt;&amp;quot;&gt;&lt;?php echo $item&#x5B;&#039;Comment&#039;]&#x5B;&#039;comment_author&#039;]; ?&gt;&lt;\/a&gt;\r\n\t\t\t&lt;?php endif; ?&gt;\r\n\t\t\ton\r\n\t\t\t&lt;a href=&amp;quot;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;guid&#039;]; ?&gt;&amp;quot;&gt;\r\n\t\t\t&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;post_title&#039;]; ?&gt;\r\n\t\t\t&lt;\/a&gt;\r\n\t\t&lt;\/li&gt;\r\n\t&lt;?php endforeach ; ?&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<p>\u958b\u767a\u6642\u306e\u624b\u9806\u306f\u3001<\/p>\n<ol>\n<li>\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u30c6\u30fc\u30d6\u30eb\u30bf\u30b0\u3067\u3001\u5fc5\u8981\u306a\u90e8\u54c1\u3092\u63c3\u3048\u3066\u304a\u304f\uff06\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002<\/li>\n<li>\u30c7\u30b6\u30a4\u30ca\u304c\u3001\u90e8\u54c1\u3092\u30b3\u30d4\u30fc\uff06\u30da\u30fc\u30b9\u30c8\u3057\u306a\u304c\u3089\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u7d44\u3080\u3002<\/li>\n<\/ol>\n<p>\u3063\u3066\u611f\u3058\u3067\u3059\u304b\u306d\u3002&lt;?php echo &#8230; ?&gt;\u306a\u3068\u3053\u308d\u306b\u5024\u304c\u5165\u308b\u3063\u3066\u3053\u3068\u3060\u3051\u8aac\u660e\u3059\u308c\u3070\u5f8c\u306f CSS \u3067\u30c7\u30b6\u30a4\u30f3\u3057\u3066\u3082\u3089\u3046\u3068\u304b\u3002<\/p>\n<p># \u5b9f\u306f Microsoft \u306e Expression Design \u306f\u3001\u4eee\u30c7\u30fc\u30bf\u3092 XML \u306a\u3069\u3067\u4f5c\u3063\u3066\u304a\u3044\u3066\u3001\u30c7\u30b6\u30a4\u30f3\u6642\u306b\u3082\u30c7\u30fc\u30bf\u304c\u8868\u793a\u3055\u308c\u308b\u3001\u3063\u3066\u306e\u304c\u58f2\u308a\u306a\u3093\u3067\u3059\u304c\u3001\u3001\u3001\u3053\u308c\u3063\u3066\u3042\u307e\u308a\u5ba3\u4f1d\u3055\u308c\u3066\u3044\u306a\u3044\u6c17\u304c\u3002\u3063\u3066\u3001\u4f7f\u3063\u3066\u3044\u308b\u4eba\u3063\u3066\u3069\u306e\u304f\u3089\u3044\uff1f\u3063\u3066\u611f\u3058\u306a\u306e\u3067\u3059\u304c\u3002<\/p>\n<p>\u25a0\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u308b<\/p>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f\u3042\u3063\u3055\u308a\u3068\u4f5c\u308a\u307e\u3057\u305f\u3002<br \/>\n\u307e\u3042\u3001\u5168\u4f53\u7528\u306e index \u30e1\u30bd\u30c3\u30c9\u3068\u6700\u65b0\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u53d6\u308b recent \u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\nclass CommentsController extends AppController {\r\n\r\n\tvar $name = &#039;Comments&#039;;\r\n\tfunction index() {\r\n\t\t$this-&gt;set(&#039;Comments&#039;,$this-&gt;Comment-&gt;find(&#039;all&#039;));\r\n\t}\r\n\tfunction recent() {\r\n\t\t$this-&gt;set(&#039;Comments&#039;,$this-&gt;Comment-&gt;findRecentComments(5));\r\n\t}\r\n}\r\n?&gt;\r\n<\/pre>\n<p>CakePHP \u306e Model::find \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u3044\u3066\u6c17\u3065\u3044\u305f\u306e\u3067\u3059\u304c\u3001web \u306e\u5834\u5408\u3001mysql \u306e limit\uff08\u884c\u6570\u5236\u9650\uff09\u306f\u5fc5\u9808\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306d\u3002\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3060\u3068\u3001\u9593\u9055\u3063\u3066\u6570\u4e07\u884c\u3092\u51fa\u3057\u3066\u3082\u30a2\u30d7\u30ea\u3092\u6b62\u3081\u308c\u3070\u63a5\u7d9a\u304c\u5207\u308c\u308b\u306e\u3067\u30b5\u30fc\u30d0\u30fc\u306e\u30c0\u30a6\u30f3\u304c\u907f\u3051\u3089\u308c\u307e\u3059\u304c\u3001web \u7d4c\u7531\u306e\u63a5\u7d9a\u3060\u3068\u3042\u3063\u3068\u3044\u3046\u9593\u306b\u30c0\u30a6\u30f3\u3057\u3066\u3057\u307e\u3044\u305d\u3046\u3002\u306a\u306e\u3067\u3001\u5fc5\u305a limit \u3092\u6307\u5b9a\u3057\u3066\u304a\u3044\u3066\u6700\u521d\u306e\u6570\u767e\u884c\u306b\u6291\u3048\u3066\u304a\u304f\u3068\u3044\u3046\u306e\u304c\u5b89\u5168\u3060\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n# SQL Server \u3084 Oracle \u3060\u3068 top \u30b3\u30de\u30f3\u30c9<\/p>\n<p>\u25a0\u30e2\u30c7\u30eb\u3092\u4f5c\u308b<\/p>\n<p>Comment.comment_post_ID (*)-(1) Post.ID \u306e\u9023\u643a\u304c\u3042\u308b\u306e\u3067\u3001Model::$belongTo \u5909\u6570\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002\u5b9f\u969b\u306f inner join \u306b\u3057\u305f\u3044\u3068\u3053\u308d\u3067\u3059\u304c\u3001Comment \u306e\u89aa\u306b\u306f\u5fc5\u305a Post \u304c\u3042\u308b\u306e\u3067\u3001\u7d50\u679c\u306f\u540c\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;!-- models\/comment.php --&gt;\r\n&lt;?php\r\nclass Comment extends AppModel\r\n{\r\n\tvar $name = &#039;Comment&#039;;\r\n\r\n\tvar $belongsTo = array(\r\n\t    &#039;Post&#039; =&gt; array(\r\n\t\t\t\t&#039;conditions&#039; =&gt; array(\r\n\t\t\t\t\tarray(&#039;Post.post_status&#039;=&gt;&#039;publish&#039;),\r\n\t\t\t\t\tarray(&#039;Comment.comment_approved&#039;=&gt;&#039;1&#039;)),\r\n\t\t\t&#039;className&#039; =&gt; &#039;Post&#039;,\r\n\t\t\t&#039;foreignKey&#039; =&gt; &#039;comment_post_ID&#039; ));\r\n\r\n\t\/\/ \u6700\u8fd1\u6295\u7a3f\u3057\u305f\u8a18\u4e8b\u3092\u53d6\u5f97\u3059\u308b\r\n\tfunction findRecentComments($max = 5) {\r\n\t\treturn parent::find(&#039;all&#039;, \r\n\t\t\tarray(\r\n\t\t\t\t&#039;conditions&#039; =&gt; array(\r\n\t\t\t\t\tarray(&#039;Post.post_status&#039;=&gt;&#039;publish&#039;),\r\n\t\t\t\t\tarray(&#039;Comment.comment_approved&#039;=&gt;&#039;1&#039;)),\r\n\t\t\t\t&#039;order&#039;=&gt;&#039;comment_date desc&#039;,\r\n                &#039;limit&#039;=&gt;$max));\r\n\t}\r\n}\r\n?&gt;\r\n<\/pre>\n<p>\u6700\u8fd1\u6295\u7a3f\u3055\u308c\u305f\u30b3\u30e1\u30f3\u30c8\u306e\u307b\u3046\u306f\u3001\u6700\u5927\u5024\u3092\u6307\u5b9a\u3057\u3066\u3001\u65e5\u4ed8\u3092\u9006\u9806\u306b\u3057\u3066\u8868\u793a\u3002<br \/>\n\u3042\u3068\u3001\u8a18\u4e8b(Post)\u306e\u65b9\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u5909\u308f\u3063\u305f\u5834\u5408\u306b\u3082\u5bfe\u51e6\u3059\u308b\u305f\u3081\u306b\u3001Model::$belongsTo \u306e\u307b\u3046\u306b\u3001conditions \u3092\u8ffd\u52a0\u3057\u3066\u304a\u304d\u307e\u3059\u3002\u3053\u3046\u3059\u308b\u3068\u3001left join \u306e on \u306e\u3068\u3053\u308d\u306b\u6761\u4ef6\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u25a0\u7d50\u679c<\/p>\n<p>\u3053\u308c\u3082\u7d50\u679c\u304c\u898b\u308c\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/wpcake.moonmile.net\/comments\/recent\">http:\/\/wpcake.moonmile.net\/comments\/recent<\/a><br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2011\/02\/wpid-dworkblogimage20110201_01org1.jpg\"><img decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2011\/02\/wpid-dworkblogimage20110201_01thum1.jpg\" border=\"0\" \/><\/a><\/p>\n<p>\u3068\u8a00\u3046\u8a33\u3067\u3001\u304a\u6b21\u306f\u30ab\u30c6\u30b4\u30ea\u4e00\u89a7\u3068\u30ab\u30c6\u30b4\u30ea\u5185\u306e\u8868\u793a\u3001\u3053\u308c\u304c wordpress \u3067\u306f\u3001\u3084\u3084\u3053\u3057\u3044\u90e8\u985e\u306a\u306e\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5ea6\u306f\u3001wordpress \u306e\u30b3\u30e1\u30f3\u30c8\u8868\u793a CakePHP \u304b\u3089 wordpress \u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046 | Moonmile Solutions Blog http:\/\/www.moonmile.net\/blog\/arch &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/1896\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[],"class_list":["post-1896","post","type-post","status-publish","format-standard","hentry","category-cakephp","category-wordpress"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/1896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=1896"}],"version-history":[{"count":5,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/1896\/revisions"}],"predecessor-version":[{"id":1898,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/1896\/revisions\/1898"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=1896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=1896"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=1896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}