{"id":851,"date":"2014-02-26T16:00:02","date_gmt":"2014-02-26T07:00:02","guid":{"rendered":"http:\/\/www.beeete2.com\/blog\/?p=851"},"modified":"2018-02-21T22:24:34","modified_gmt":"2018-02-21T13:24:34","slug":"post-851","status":"publish","type":"post","link":"https:\/\/www.beeete2.com\/blog\/?p=851","title":{"rendered":"CakePHP\u3067\u7c21\u5358\u306a\u30e2\u30c7\u30eb\u3092\u4f5c\u308b"},"content":{"rendered":"<p>\u524d\u56de\u3001\u7c21\u5358\u306a\u30d3\u30e5\u30fc\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u3063\u305f\u306e\u3067\u4eca\u56de\u306f\u30e2\u30c7\u30eb\u3092\u4f5c\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u30c6\u30fc\u30d6\u30eb\u540d\u3068\u4f5c\u6210\u3059\u308b\u30e2\u30c7\u30eb\u30d5\u30a1\u30a4\u30eb\u540d\u306fCakePHP\u306e\u547d\u540d\u898f\u5247\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u57fa\u672c\u7684\u306b\u306f\u305d\u306e\u30eb\u30fc\u30eb\u306b\u3057\u305f\u304c\u3063\u3066\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u307e\u305a\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\n<!--more--><\/p>\n<h4>\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210<\/h4>\n<p>\u4eca\u56de\u30c6\u30b9\u30c8\u7528\u306bCakePHP\u306e\u8a8d\u8a3c\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u5185\u3067\u4f7f\u308f\u308c\u3066\u3044\u308busers\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u3044\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/book.cakephp.org\/2.0\/ja\/tutorials-and-examples\/blog-auth-example\/auth.html\" target=\"_blank\">\u30b7\u30f3\u30d7\u30eb\u306a\u8a8d\u8a3c\u3068\u627f\u8a8d\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3<\/a><br \/>\n[sql]<br \/>\nCREATE TABLE users (<br \/>\n    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,<br \/>\n    username VARCHAR(50),<br \/>\n    password VARCHAR(50),<br \/>\n    role VARCHAR(20),<br \/>\n    created DATETIME DEFAULT NULL,<br \/>\n    modified DATETIME DEFAULT NULL<br \/>\n);<br \/>\n[\/sql]<br \/>\nXAMPP\u3092\u304a\u4f7f\u3044\u306e\u304b\u305f\u306fphpMyAdmin\u7b49\u3067SQL\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u52d5\u4f5c\u78ba\u8a8d\u7528\u306b\uff12\u4ef6\u307b\u3069INSERT\u3057\u3066\u304a\u304d\u307e\u3059\u3002<br \/>\n[sql]<\/p>\n<p>INSERT INTO users (<br \/>\nusername,<br \/>\npassword,<br \/>\nrole,<br \/>\ncreated<br \/>\n) VALUES(&#8216;admin&#8217;, &#8216;admin&#8217;, &#8216;admin&#8217;, NOW());<br \/>\nINSERT INTO users (<br \/>\nusername,<br \/>\npassword,<br \/>\nrole,<br \/>\ncreated<br \/>\n) VALUES(&#8216;user&#8217;, &#8216;user&#8217;, &#8216;user&#8217;, NOW());<br \/>\n[\/sql]<\/p>\n<h4>\u30e2\u30c7\u30eb\u306e\u4f5c\u6210<\/h4>\n<p>\u6b21\u306b\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u6700\u521d\u306b\u4f5c\u6210\u3059\u308b\u30e2\u30c7\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306f<br \/>\nUser.php<br \/>\n\u3068\u306a\u308a\u307e\u3059\u3002\u30c6\u30fc\u30d6\u30eb\u540d\u306fusers\u3068\u8907\u6570\u7cfb\u3067\u3059\u304c\u5bfe\u5fdc\u3059\u308b\u30e2\u30c7\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306fUser\u3068\u5358\u6570\u5f62\u306b\u306a\u308b\u3053\u3068\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<br \/>\ncake\/app\/Model\/User.php<br \/>\n\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n[php]<br \/>\n&lt;?php<br \/>\nclass User extends AppModel {<br \/>\n}<br \/>\n[\/php]<\/p>\n<h4>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u4f5c\u6210<\/h4>\n<p>\u753b\u9762\u4e0a\u304b\u3089\u64cd\u4f5c\u3067\u304d\u308b\u3088\u3046\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\ncake\/app\/Controller\/UsersController.php<br \/>\n\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002\u30e2\u30c7\u30eb\u3068\u306f\u9055\u3044\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306fUsers\u3068\u8907\u6570\u7cfb\u306b\u306a\u308b\u3053\u3068\u306b\u6ce8\u610f\u3002<br \/>\n[php]<br \/>\n&lt;?php<br \/>\nclass UsersController extends AppController {<br \/>\n\tpublic function index() {<br \/>\n\t\t$this-&gt;set(&#8216;User&#8217;, $this-&gt;User-&gt;find(&#8216;all&#8217;));<br \/>\n\t}<br \/>\n}<br \/>\n[\/php]<\/p>\n<h4>\u30d3\u30e5\u30fc\u306e\u4f5c\u6210<\/h4>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5185\u5bb9\u3092\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\ncake\/app\/View\/Users\/index.ctp<br \/>\n\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n[php]<br \/>\n&lt;?php debug($User); ?&gt;<br \/>\n[\/php]<br \/>\n\u30ec\u30b3\u30fc\u30c9\u306e\u5185\u5bb9\u3092\u30c7\u30d0\u30c3\u30b0\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<h4>\u52d5\u4f5c\u78ba\u8a8d<\/h4>\n<p>\u3053\u306e\u72b6\u614b\u3067http:\/\/localhost\/cake\/users\/\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u69d8\u306a\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2014\/02\/result1.png\"><img decoding=\"async\" src=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2014\/02\/result1.png\" alt=\"result1\" width=\"1178\" height=\"877\" class=\"alignnone size-full wp-image-860\" srcset=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2014\/02\/result1.png 1178w, https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2014\/02\/result1-300x223.png 300w, https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2014\/02\/result1-1024x762.png 1024w\" sizes=\"(max-width: 1178px) 100vw, 1178px\" \/><\/a><br \/>\n\u30d1\u30b9\u30ef\u30fc\u30c9\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u81ea\u52d5\u7684\u306b****\u3067\u30de\u30b9\u30af\u3055\u308c\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<h4>\u7d50\u3073\u306b<\/h4>\n<p>find\u30e1\u30bd\u30c3\u30c9\u306b\u3064\u3044\u3066\u306f\u3001\u3082\u3061\u308d\u3093\u691c\u7d22\u6761\u4ef6\u306a\u3069\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3066\u7c21\u5358\u306aSQL\u6587\u3067\u3042\u308c\u3070SQL\u6587\u3092\u66f8\u304f\u3053\u3068\u306a\u304f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u308b\u306e\u306f\u975e\u5e38\u306b\u7c21\u5358\u3067\u3059\u306d\u3002<br \/>\n\u3057\u304b\u3057\u306a\u304c\u3089\u8907\u96d1\u306aSQL\u6587\u3001\u4f8b\u3048\u3070\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u3092\u8a2d\u5b9a\u3057\u305f\u308a\u3059\u308b\u3082\u306e\u306b\u95a2\u3057\u3066\u306fSQL\u6587\u3067\u66f8\u3044\u305f\u307b\u3046\u304c\u3088\u3044\u306e\u304b\u8ff7\u3046\u90e8\u5206\u3067\u306f\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u8fba\u308a\u306f\u4f5c\u6210\u3059\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u52d8\u5b9a\u3057\u3066\u5224\u65ad\u3059\u308b\u306e\u304c\u3088\u3044\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u3001\u7c21\u5358\u306a\u30d3\u30e5\u30fc\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u3063\u305f\u306e\u3067\u4eca\u56de\u306f\u30e2\u30c7\u30eb\u3092\u4f5c\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u30c6\u30fc\u30d6\u30eb\u540d\u3068\u4f5c\u6210\u3059\u308b\u30e2\u30c7\u30eb\u30d5\u30a1\u30a4\u30eb\u540d\u306fCakePHP\u306e\u547d\u540d\u898f\u5247\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u57fa\u672c\u7684\u306b\u306f\u305d\u306e\u30eb\u30fc\u30eb\u306b\u3057\u305f\u304c\u3063\u3066\u4f5c\u6210 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":839,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"views":11885,"_links":{"self":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/851"}],"collection":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=851"}],"version-history":[{"count":11,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/851\/revisions"}],"predecessor-version":[{"id":1741,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/851\/revisions\/1741"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/839"}],"wp:attachment":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}