{"id":1888,"date":"2011-01-31T17:38:10","date_gmt":"2011-01-30T23:38:10","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/1888"},"modified":"2011-01-31T17:42:30","modified_gmt":"2011-01-31T08:42:30","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%86","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/1888","title":{"rendered":"CakePHP \u304b\u3089 wordpress \u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046"},"content":{"rendered":"<p>\u518d\u3073 CakePHP \u672c\u4f53\u306b\u623b\u3063\u3066\u3001\u305d\u306e\u5b9f\u529b\u306a\u305e&#8230;\u3068\u3044\u3046\u304b\u81ea\u5206\u7684\u306b\u8abf\u67fb\u3002<\/p>\n<p>\u305d\u3046\u3044\u3048\u3070\u3001v1.3.x \u304b\u3089\u306f Model::findAll \u30e1\u30bd\u30c3\u30c9\u304c\u52d5\u304b\u305a Model::find(&#8216;all&#8217;) \u306b\u5207\u308a\u66ff\u3048\u3089\u308c\u305f\u3093\u3060\u305d\u3046\u3060\u3002<\/p>\n<p>find :: \u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b :: \u30e2\u30c7\u30eb :: CakePHP\u306b\u3088\u308b\u958b\u767a :: \u30de\u30cb\u30e5\u30a2\u30eb :: 1.3\u30b3\u30ec\u30af\u30b7\u30e7\u30f3 :: The Cookbook<br \/>\n<a href=\"http:\/\/book.cakephp.org\/ja\/view\/1018\/find\">http:\/\/book.cakephp.org\/ja\/view\/1018\/find<\/a><\/p>\n<p>\u3053\u306e\u5909\u66f4\u306f\u3001\u3061\u3068\u5927\u304d\u3044\u306e\u304b\u306a\u3041\u3002\u53e4\u3044\u30de\u30cb\u30e5\u30a2\u30eb\u3092\u8aad\u3093\u3067\u3044\u308b\u3068 findAll \u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u304c\u591a\u3044\u306e\u3067\u3001\u60a9\u3093\u3060\u308a\u3057\u307e\u3059\u3002\u56e0\u307f\u306b\u3001findAllBy\u30ab\u30e9\u30e0\u540d \u306f\u52d5\u304f\u3093\u3067\u3059\u3088\u306d(\u4f55\u6545\u304b\u3001findAll \u3060\u3051\u304c\u52d5\u304b\u306a\u3044\u3068\u3044\u3046\u73fe\u8c61\u3067\u60a9\u3093\u3060)<\/p>\n<p>wordpress \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u69cb\u9020\u306f\u6bd4\u8f03\u7684\u7c21\u5358\u3067\u300111 \u500b\u3057\u304b\u3042\u308a\u307e\u305b\u3093\u3002\u8a73\u3057\u3044\u3068\u3053\u308d\u306f\u3001<\/p>\n<p>Amazon.co.jp\uff1a PHP\u306b\u3088\u308bWordPress\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u30d6\u30c3\u30af\u20152.8\u5bfe\u5fdc \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u6539\u9020\u304b\u3089\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u4f5c\u6210\u307e\u3067: \u85e4\u672c \u58f1: \u672c<br \/>\n[amazon http:\/\/www.amazon.co.jp\/dp\/4883376745]<\/p>\n<p>\u3092\u53c2\u7167\u3057\u3066\u8cb0\u3046\u3068\u3057\u3066\u30022.8 \u30d9\u30fc\u30b9\u306a\u306e\u3067\u3059\u304c\u3001\u79c1\u7684\u306b\u306f\u3053\u308c\u3067\u5341\u5206\u306a\u72b6\u614b\u3002<\/p>\n<ul>\n<li>wp_posts: \u6295\u7a3f\u8a18\u4e8b\/\u30da\u30fc\u30b8<\/li>\n<li>wp_comments: \u30b3\u30e1\u30f3\u30c8<\/li>\n<li>wp_users: \u30e6\u30fc\u30b6\u30fc\u60c5\u5831<\/li>\n<\/ul>\n<p>\u3042\u3068\u3001\u30ab\u30c6\u30b4\u30ea\u3084\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u95a2\u4fc2\u304c<\/p>\n<ul>\n<li>wp_terms<\/li>\n<li>wp_term_taxonomy<\/li>\n<li>wp_term_relationships<\/li>\n<\/ul>\n<p>\u306b\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306e\u95a2\u4fc2\u3092\u3001CakePHP \u304b\u3089\u6271\u3046\u306b\u306f\u3069\u3046\u3059\u308b\u306e\u304b\uff1f\u3063\u3066\u306e\u3092\u5b9f\u8df5\u3057\u3066\u307f\u308c\u3070\u3001\u5b9f\u904b\u7528\u3067\u4f7f\u3048\u308b\u6280\u8853\u304c\u935b\u3048\u3089\u308c\u308b\u306f\u305a\u3002<\/p>\n<p>\u3072\u3068\u307e\u305a\u3001\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u306e\u300cwp_\u300d\u304c\u90aa\u9b54\u306a\u306e\u3067\u3059\u304c\u3001CakePHP \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a2d\u5b9a\u3067 prefix \u3092\u6307\u5b9a\u3067\u304d\u308b\u306e\u3067\u3001\u3053\u308c\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nclass DATABASE_CONFIG {\r\n\tvar $default = array(\r\n\t\t&#039;driver&#039; =&gt; &#039;mysql&#039;,\r\n\t\t&#039;persistent&#039; =&gt; false,\r\n\t\t&#039;host&#039; =&gt; &#039;127.0.0.1&#039;,\r\n\t\t&#039;login&#039; =&gt; &#039;manabook&#039;,\r\n\t\t&#039;password&#039; =&gt; &#039;manabook&#039;,\r\n\t\t&#039;database&#039; =&gt; &#039;manabook&#039;,\r\n\t\t&#039;prefix&#039; =&gt; &#039;wp_&#039;,\t\u2605\r\n\t);\r\n<\/pre>\n<p>\u3053\u3046\u3057\u3066\u304a\u304f\u3068\u3001\u30c6\u30fc\u30d6\u30eb\u540d\u304c\u300cwp_posts\u300d\u3067\u3082 Post \u30e2\u30c7\u30eb\u3068\u3057\u3066\u53c2\u7167\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u25a0\u6700\u521d\u306fURL\u3092\u5165\u308c\u308b<\/p>\n<p>CakePHP \u306f\u30de\u30cb\u30e5\u30a2\u30eb\u7121\u3057\u3067\u30b5\u30a4\u30c8\u3092\u4f5c\u308c\u308b\u306e\u304b\uff1f | Moonmile Solutions Blog<br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/archives\/1753\">http:\/\/www.moonmile.net\/blog\/archives\/1753<\/a>\u00a0<\/p>\n<p>\u81ea\u5206\u3067\u3084\u3063\u305f\u3053\u3068\u3092\u3001\u3082\u3046\u4e00\u5ea6\u8a66\u3057\u3066\u307f\u308b\u308b\u306e\u3067\u3001\u6700\u521d\u306f url \u3092\u6c7a\u3081\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/servername\/posts\">http:\/\/servername\/posts<\/a><\/p>\n<p>\u3068\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<p>\u25a0\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u4f5c\u308b<\/p>\n<p>\u5f53\u7136\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u7121\u3044\u3068\u306e\u304a\u9054\u3057\u306a\u306e\u3067\u3001PostsController \u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\nclass PostsController extends AppController {\r\n\r\n\tvar $name = &#039;Posts&#039;;\r\n\t\/\/ \u3072\u3068\u307e\u305a\u4e00\u89a7\r\n\tfunction index() {\r\n\t\t$this-&gt;set(&#039;Posts&#039;,$this-&gt;Post-&gt;findPublish());\r\n\t}\r\n\t\/\/ \u6700\u8fd1\u306e\u4e00\u89a7\r\n\tfunction recent() {\r\n\t\t$this-&gt;set(&#039;Posts&#039;,$this-&gt;Post-&gt;findRecentPosts(5));\r\n\t}\r\n}\r\n?&gt;\r\n<\/pre>\n<p>\u3053\u3053\u3067 findPublish \u30e1\u30bd\u30c3\u30c9\u3068 findRecnetPosts \u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u306f wp_posts \u306f\u3001\u516c\u958b(post_status)\u306e\u72b6\u614b\u304c\u3042\u3063\u3066\u3001\u4e00\u89a7\u306e\u5834\u5408\u306f\u3053\u306e\u30ab\u30e9\u30e0\u3092\u5fc5\u305a\u307f\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u6761\u4ef6\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u6307\u5b9a\u3057\u3066\u3082\u3088\u3044\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u306f Post \u30e2\u30c7\u30eb\u306b\u4efb\u305b\u308b\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u25a0\u30e2\u30c7\u30eb\u3092\u4f5c\u308b<\/p>\n<p>\u8272\u3005\u8a66\u884c\u932f\u8aa4\u3057\u305f\u7d50\u679c\u3001\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;!-- models\/post.php --&gt;\r\n&lt;?php\r\nclass Post extends AppModel\r\n{\r\n\tvar $name = &#039;Post&#039;;\r\n\r\n\tvar $belongsTo = array(\r\n\t    &#039;User&#039; =&gt; array(\r\n\t\t\t&#039;className&#039; =&gt; &#039;User&#039;,\r\n\t\t\t&#039;foreignKey&#039; =&gt; &#039;post_author&#039; ));\r\n\r\n\tfunction findPublish() {\r\n\t\treturn parent::find(&#039;all&#039;,\r\n\t\t\tarray(&#039;conditions&#039; =&gt; array(&#039;Post.post_status&#039;=&gt;&#039;publish&#039;),\r\n\t\t\t\t  &#039;order&#039;=&gt;&#039;post_date&#039;));\r\n\t}\r\n\t\/\/ \u6700\u8fd1\u6295\u7a3f\u3057\u305f\u8a18\u4e8b\u3092\u53d6\u5f97\u3059\u308b\r\n\tfunction findRecentPosts($max = 5) {\r\n\t\treturn parent::find(&#039;all&#039;,\r\n\t\t\tarray(&#039;conditions&#039; =&gt; array(&#039;Post.post_status&#039;=&gt;&#039;publish&#039;),\r\n\t\t\t\t  &#039;order&#039;=&gt;&#039;post_date desc&#039;,\r\n\t\t\t\t  &#039;limit&#039;=&gt;$max));\r\n\t}\r\n}\r\n?&gt;\r\n<\/pre>\n<p>Model::find \u30e1\u30bd\u30c3\u30c9\u306e\u8a18\u6cd5\u304c\u3084\u3084\u3053\u3057\u3044\u306e\u3067\u3059\u304c\u3001Post.post_status \u306e $conditions \u3092\u5fc5\u305a\u3044\u308c\u3066\u304a\u3044\u3066\u3001\u5f8c\u306f order by \u3059\u308b\u306e\u3092\u5fd8\u308c\u306a\u3044\u3088\u3046\u306b\u3002<\/p>\n<p>Model::$belongsTo \u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u306e\u306f\u3001\u6295\u7a3f\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u540d(wp_user)\u306b\u30ea\u30f3\u30af\u3055\u305b\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>\u25a0\u30d3\u30e5\u30fc\u3092\u4f5c\u308b<\/p>\n<p>\u3053\u308c\u3092\u8e0f\u307e\u3048\u3066\u3001\u3056\u3063\u304f\u308a\u3068\u30d3\u30e5\u30fc\u3092\u4f5c\u308b\u3068\u3001<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;table&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;th&gt;ID&lt;\/th&gt;\r\n\t\t&lt;th&gt;post_date&lt;\/th&gt;\r\n\t\t&lt;th&gt;post_title&lt;\/th&gt;\r\n\t\t&lt;th&gt;guid&lt;\/th&gt;\r\n\t&lt;\/tr&gt;\r\n\t&lt;?php foreach($Posts as $item) : ?&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;ID&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;post_date&#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<\/pre>\n<p>\u307e\u3042\u3001\u3072\u3068\u307e\u305a\u306f\u30c6\u30fc\u30d6\u30eb\u8868\u793a\u3092\u3059\u308b\u3060\u3051\u3002\u4e0b\u8a18\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/wpcake.moonmile.net\/posts\">http:\/\/wpcake.moonmile.net\/posts<\/a><br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2011\/01\/wpid-dworkblogimage20110131_06org.jpg\"><img decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2011\/01\/wpid-dworkblogimage20110131_06thum.jpg\" border=\"0\" \/><\/a><\/p>\n<p>\u25a0\u6700\u8fd1\u6295\u7a3f\u3057\u305f\u8a18\u4e8b\u3082\u8868\u793a\u3055\u305b\u308b<\/p>\n<p>wordpress \u306e\u3088\u3046\u306b\u6700\u8fd1\u6295\u7a3f\u3057\u305f\u8a18\u4e8b(recent posts)\u3082\u8868\u793a\u3055\u305b\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;h2&gt;\u6700\u8fd1\u6295\u7a3f\u3057\u305f\u8a18\u4e8b&lt;\/h2&gt;\r\n&lt;table&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;th&gt;ID&lt;\/th&gt;\r\n\t\t&lt;th&gt;post_date&lt;\/th&gt;\r\n\t\t&lt;th&gt;post_title&lt;\/th&gt;\r\n\t&lt;\/tr&gt;\r\n\t&lt;?php foreach($Posts as $item) : ?&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;ID&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;post_date&#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;post_author&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;User&#039;]&#x5B;&#039;user_nicename&#039;]; ?&gt;\r\n\t\t&lt;td&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;guid&#039;]; ?&gt;\r\n\r\n\t&lt;\/tr&gt;\r\n\t&lt;?php endforeach ; ?&gt;\r\n&lt;\/table&gt;\r\n&lt;h2&gt;\u6700\u8fd1\u6295\u7a3f\u3057\u305f\u8a18\u4e8b(\u30ea\u30f3\u30af\u7248)&lt;\/h2&gt;\r\n&lt;ul&gt;\r\n&lt;?php foreach($Posts as $item) : ?&gt;\r\n\t&lt;li&gt;\r\n\t\t&lt;a href=&amp;quot;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;guid&#039;]; ?&gt;&amp;quot;&gt;&lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;post_title&#039;]; ?&gt;&lt;\/a&gt; by &lt;?php echo $item&#x5B;&#039;User&#039;]&#x5B;&#039;user_nicename&#039;]; ?&gt; at &lt;?php echo $item&#x5B;&#039;Post&#039;]&#x5B;&#039;post_date&#039;]; ?&gt;\r\n\t&lt;\/li&gt;\r\n&lt;?php endforeach; ?&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<p>\u5148\u306b\u30c6\u30fc\u30d6\u30eb\u3067\u5024\u3092\u78ba\u8a8d\u3057\u305f\u5f8c\u306b\u3001\u30da\u30bf\u30da\u30bf\u3068\u30ea\u30f3\u30af\u306e\u8868\u793a\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u4e0b\u8a18\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/wpcake.moonmile.net\/posts\/recent\">http:\/\/wpcake.moonmile.net\/posts\/recent<\/a><br \/>\n<a href=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2011\/01\/wpid-dworkblogimage20110131_07org.jpg\"><img decoding=\"async\" src=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2011\/01\/wpid-dworkblogimage20110131_07thum.jpg\" border=\"0\" \/><\/a><\/p>\n<p>\u304a\u6b21\u306f\u3001\u30b3\u30e1\u30f3\u30c8\u4e00\u89a7\u306a\u305e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u518d\u3073 CakePHP \u672c\u4f53\u306b\u623b\u3063\u3066\u3001\u305d\u306e\u5b9f\u529b\u306a\u305e&#8230;\u3068\u3044\u3046\u304b\u81ea\u5206\u7684\u306b\u8abf\u67fb\u3002 \u305d\u3046\u3044\u3048\u3070\u3001v1.3.x \u304b\u3089\u306f Model::findAll \u30e1\u30bd\u30c3\u30c9\u304c\u52d5\u304b\u305a Model::find(&#8216;all&#038;#82 &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/1888\">\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-1888","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\/1888","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=1888"}],"version-history":[{"count":2,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/1888\/revisions"}],"predecessor-version":[{"id":1890,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/1888\/revisions\/1890"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=1888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=1888"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=1888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}