{"id":5,"date":"2013-10-07T14:19:08","date_gmt":"2013-10-07T05:19:08","guid":{"rendered":"http:\/\/www.otwo.jp\/blog\/?p=5"},"modified":"2015-01-14T11:06:28","modified_gmt":"2015-01-14T02:06:28","slug":"framework","status":"publish","type":"post","link":"https:\/\/www.otwo.jp\/blog\/framework\/","title":{"rendered":"\u30bd\u30fc\u30b7\u30e3\u30eb\u30b2\u30fc\u30e0\u7528\u306ePHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af"},"content":{"rendered":"<p>\u958b\u767a\uff12\u90e8\u306e\u5409\u5ca1\u3067\u3059\u3002<\/p>\n<p>PHP\u3067\u30bd\u30fc\u30b7\u30e3\u30eb\u30b2\u30fc\u30e0\u3092\u4f5c\u3063\u3066\u3044\u308b\u4f1a\u793e\u306f\u591a\u3044\u304b\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001<br \/>\n\u30aa\u30fc\u30c4\u30fc\u3067\u306f\u3001\u81ea\u5206\u305f\u3061\u3067\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f5c\u3063\u3066\u958b\u767a\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<!--more--><\/p>\n<p>\u65e2\u5b58\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u308f\u306a\u304b\u3063\u305f\u306e\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3084\u30ad\u30e3\u30c3\u30b7\u30e5\u7528\u306eKVS\u3092\u67d4\u8edf\u306b\u4f7f\u3044\u305f\u304b\u3063\u305f\u3068\u3044\u3046\u7406\u7531\u3068\u3001\u5358\u7d14\u306b\u6280\u8853\u529b\u306e\u5411\u4e0a\u76ee\u7684\u3067\u3059\u3002<\/p>\n<p>\u9ad8\u8ca0\u8377\u306a\u30b2\u30fc\u30e0\u3082\u30b3\u30a4\u30c4\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u306a\u304b\u306a\u304b\u826f\u3044\u611f\u3058\u3067\u4f7f\u3048\u3066\u3044\u307e\u3059\u3002<br \/>\n\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u554f\u984c\u304c\u3042\u3063\u3066\u3082\u3001\u30d6\u30e9\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u5316\u3057\u305f\u30b3\u30fc\u30c9\u304c\u306a\u3044\u306e\u3067\u3001\u539f\u56e0\u306e\u8abf\u67fb\u3082\u3057\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<h1>\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u4e2d\u8eab<\/h1>\n<p>\u3053\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u5185\u5bb9\u3092\u3056\u3063\u304f\u308a\u5206\u3051\u308b\u3068\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<h2>ActionHandler<\/h2>\n<p>\u30ea\u30af\u30a8\u30b9\u30c8URL\u304b\u3089\u3001\u547c\u3073\u51fa\u3059Action\u30af\u30e9\u30b9\u6c7a\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h2>Action<\/h2>\n<p>\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5408\u3063\u305f\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u3001Logic\u306e\u547c\u3073\u51fa\u3057\u3001\u305d\u306e\u8fd4\u5374\u5024\u3092\u5143\u306b\u51fa\u529b\u3059\u308b\u5185\u5bb9\u3092\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001Validation\u3084\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u7b49\u3067\u767a\u751f\u3057\u305f\u4f8b\u5916\u3092\u4e00\u624b\u306bcatch\u3057\u3066\u5bfe\u5fdc\u3057\u305f\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3053\u3093\u306a\u611f\u3058\uff08\u304b\u306a\u308a\u7aef\u6298\u3063\u3066\u3044\u307e\u3059\u304c\u2026\uff09<\/p>\n<pre class=\"brush: php\r; notranslate\">class ActionRegist extends _Action {\r\n\r\n    protected function doAction(){\r\n        \/\/\u30ea\u30af\u30a8\u30b9\u30c8\u30af\u30a8\u30ea\u304b\u3089\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u53d6\u5f97\r\n        $user_name = $this-&gt;getQuery('user_name');\r\n        $user_password = $this-&gt;getQuery('user_password');\r\n\r\n        \/\/LogicPerson::regist\u3092\u547c\u3073\u51fa\u3057\u767b\u9332\u51e6\u7406\u3092\u884c\u3046\r\n        \/\/$this-&gt;master_db\u306f\u3001\u30de\u30b9\u30bf\u30fcDB\u30b5\u30fc\u30d0\u30fc\u3078\u306e\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\r\n        LogicPerson::regist( $this-&gt;master_db,  $user_name, $user_password );\r\n\r\n        \/\/ \u51fa\u529b\u30d1\u30e9\u30e1\u30fc\u30bf\u306bOK\u3092\u8ffd\u52a0\r\n        $this-&gt;Output-&gt;assign('result', 'ok');\r\n    }\r\n}\r\n<\/pre>\n<h2>Logic<\/h2>\n<p>\u4e3b\u306bSQL\u3092\u4f5c\u6210\u3057\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u3084\u308a\u3068\u308a\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30af\u30e9\u30b9\u306fstatic\u306b\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002\u306a\u306e\u3067\u3001\u30e1\u30bd\u30c3\u30c9\u3082\u5168\u3066static\u3067\u3059\u3002<\/p>\n<p>\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001Action\u30af\u30e9\u30b9\u304b\u3089\u306e\u547c\u3073\u51fa\u3057\u3060\u3051\u3067\u306f\u306a\u304f\u3001\u4ed6\u306e\u51e6\u7406\u304b\u3089\u3082Logic\u30af\u30e9\u30b9\u3092\u547c\u3073\u51fa\u3057\u3084\u3059\u304f\u3057\u3066\u3044\u307e\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u3001\u30c7\u30d0\u30c3\u30b0\u30b9\u30af\u30ea\u30d7\u30c8\u3084\u30d0\u30c3\u30c1\u51e6\u7406\u306a\u3093\u304b\u304c\u4f5c\u308a\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3053\u3093\u306a\u611f\u3058<\/p>\n<pre class=\"brush: php\r; notranslate\">class LogicPerson extends _Logic {\r\n\r\n    static public function regist( _DatabaseAccess $DatabaseAccess, $user_name, $user_password){\r\n        \/\/\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\uff08_DatabaseAccess\uff09\u306einsert\u3092\u547c\u3073\u51fa\u3057\u3066\u3001\u30c7\u30fc\u30bf\u3092\u633f\u5165\u3059\u308b\r\n        if ( $DatabaseAccess-&gt;insert( 'person', $user_name, $user_password  )){\r\n            return true;\r\n        }\r\n        else {\r\n            return false;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<h2>DatabaseAccess<\/h2>\n<p>Action\u30af\u30e9\u30b9\u306e\u521d\u671f\u51e6\u7406\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3055\u308c\u308b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u63a5\u7d9a\u3084SQL\u306e\u767a\u884c\u3092\u884c\u3046\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u6271\u3046Logic\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u5fc5\u305aDatabaseAccess\u30af\u30e9\u30b9\u3092\u5f15\u6570\u306b\u6301\u3061\u307e\u3059\u3002<br \/>\n\u4e00\u898b\u3081\u3093\u3069\u304f\u3055\u3044\u5b9f\u88c5\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306emaster\u30fbslave\u3092\u660e\u78ba\u306b\u4f7f\u3044\u5206\u3051\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u3053\u306e\u30af\u30e9\u30b9\u306f\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u7ba1\u7406\u3082\u53d7\u3051\u6301\u3061\u307e\u3059\u3002<br \/>\ninsert\u30fbupdate\u306eSQL\u3092\u767a\u884c\u3059\u308b\u6642\u3001\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u304c\u81ea\u52d5\u7684\u306b\u958b\u59cb\u3055\u308c\u3001Action\u30af\u30e9\u30b9\u306e\u7d42\u308f\u308a\u306b\u30b3\u30df\u30c3\u30c8\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>Output<\/h2>\n<p>Action\u3067\u4f5c\u6210\u3055\u308c\u305f\u51fa\u529b\u5185\u5bb9\u3092\u6574\u7406\u3057\u3066\u3001\u5b9f\u969b\u306b\u51fa\u529b\u51e6\u7406\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\n\u30d6\u30e9\u30a6\u30b6\u5411\u3051\u306e\u30bd\u30fc\u30b7\u30e3\u30eb\u30b2\u30fc\u30e0\u306a\u3089\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8aad\u307f\u8fbc\u3093\u3067html\u51fa\u529b\u3092\u3057\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001\u30cd\u30a4\u30c6\u30a3\u30d6\u30a2\u30d7\u30ea\u306a\u3089\u3001JSON\u51fa\u529b\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30e9\u30b0\u30a4\u30f3\u7684\u306a\u8a2d\u8a08\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3001xml\u3067\u306e\u51fa\u529b\u306a\u3069\u306b\u3082\u5bfe\u5fdc\u51fa\u6765\u307e\u3059\u3002<\/p>\n<h1>\u30ad\u30e3\u30c3\u30b7\u30e5<\/h1>\n<p>\u904b\u55b6\u4e2d\u306b\u5024\u304c\u5909\u5316\u3057\u306a\u3044\u30c6\u30fc\u30d6\u30eb\uff08\u30ab\u30fc\u30c9\u30d1\u30e9\u30e1\u30fc\u30bf\u7b49\uff09\u306f\u3001APC\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30ad\u30e3\u30c3\u30b7\u30e5\u3055\u308c\u3066\u3044\u308b\u30c7\u30fc\u30bf\u306b\u306f\u6709\u52b9\u671f\u9650\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u4ed5\u8fbc\u3093\u3067\u3042\u308a\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u6bce\u306b\u30c1\u30a7\u30c3\u30af\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002\u3058\u3083\u306a\u3044\u3068\u3001\u30a4\u30d9\u30f3\u30c8\u671f\u9593\u304c\u7d42\u308f\u3063\u3066\u3044\u308b\u306e\u306b\u30a4\u30d9\u30f3\u30c8\u7528\u30ab\u30fc\u30c9\u304c\u51fa\u73fe\u3057\u3066\u3044\u308b\uff01\u3068\u3044\u3046\u3088\u3046\u306a\u3053\u3068\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<h1>Redis<\/h1>\n<p>\u30db\u30fc\u30e0\u753b\u9762\u306a\u3069\u30a2\u30af\u30bb\u30b9\u306e\u591a\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u306f\u3001Redis\u306b\u30c7\u30fc\u30bf\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8ca0\u8377\u8efd\u6e1b\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u65b0\u4eba\u4e00\u89a7\u3084\u5bfe\u6226\u76f8\u624b\u4e00\u89a7\u3001\u306a\u3069\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001Redis\u306f\u4ed6\u306b\u30bd\u30fc\u30c8\u6e08\u307f\u30bb\u30c3\u30c8\u3067\u30e9\u30f3\u30ad\u30f3\u30b0\u306e\u4f5c\u6210\u3082\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>Redis\u306f\u901f\u3044\uff01\u3068\u3044\u3046\u8a55\u5224\u3067\u3059\u304c\u3001\u904e\u4fe1\u3059\u308b\u3068\u3048\u3089\u3044\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u305d\u306e\u3042\u305f\u308a\u306f\u3001\u307e\u305f\u5225\u306e\u8a18\u4e8b\u3067\u3002<\/p>\n<h1>\u307e\u3068\u3081<\/h1>\n<p>\u3053\u306ePHP\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306f\u6848\u4ef6\u3054\u3068\u306b\u6210\u9577\u3057\u3066\u3044\u3066\u3001\u4eca\u5f8c\u3082\u6539\u4fee\u3057\u306a\u304c\u3089\u3055\u3089\u306b\u826f\u304f\u3057\u3066\u3044\u304f\u3064\u3082\u308a\u3067\u3059\u3002<br \/>\n\u305f\u3060\u3001\u4eca\u306fPHP5.3\u307e\u3067\u3057\u304b\u5bfe\u5fdc\u51fa\u6765\u3066\u3044\u306a\u3044\u306e\u3067\u30015.4\u30015.5\u3067\u65b0\u3057\u304f\u8ffd\u52a0\u3055\u308c\u305f\u6a5f\u80fd\u3092\u53d6\u308a\u8fbc\u3093\u3067\u884c\u304d\u305f\u3044\u3068\u3053\u3068\u3067\u3059\u3002generator\u3068\u304b\u3001finally\u53e5\u3068\u304b\u9b45\u529b\u7684\u3067\u3059\u306d\u3002<\/p>\n<p>\u3042\u308c\u3084\u3053\u308c\u3084\u6539\u4fee\u3057\u305f\u3044\u3068\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u307e\u3060\u307e\u3060\u624b\u4ed8\u304b\u305a\u3067\u3059\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u958b\u767a\uff12\u90e8\u306e\u5409\u5ca1\u3067\u3059\u3002 PHP\u3067\u30bd\u30fc\u30b7\u30e3\u30eb\u30b2\u30fc\u30e0\u3092\u4f5c\u3063\u3066\u3044\u308b\u4f1a\u793e\u306f\u591a\u3044\u304b\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001 \u30aa\u30fc\u30c4\u30fc\u3067\u306f\u3001\u81ea\u5206\u305f\u3061\u3067\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f5c\u3063\u3066\u958b\u767a\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":11,"featured_media":727,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[5],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/5"}],"collection":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":42,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":1204,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/5\/revisions\/1204"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/media\/727"}],"wp:attachment":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}