{"id":9837,"date":"2018-11-29T19:59:35","date_gmt":"2018-11-29T10:59:35","guid":{"rendered":"https:\/\/www.itblog.jp\/?p=9837"},"modified":"2019-06-09T21:18:06","modified_gmt":"2019-06-09T12:18:06","slug":"cake-php%e3%81%ae%e5%8b%89%e5%bc%b7%e3%83%a1%e3%83%a2","status":"publish","type":"post","link":"https:\/\/www.itblog.jp\/?p=9837","title":{"rendered":"Cake-php\u306e\u52c9\u5f37\u30e1\u30e2"},"content":{"rendered":"<p>Cake-php\u306f\u3001MVC\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u308bPHP\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af<\/p>\n<p>MVC\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3068\u306f\u3001Model\u3001View\u3001Conroller\u3067\u5206\u96e2\u3055\u308c\u3066\u3044\u308b\u3001\u3044\u308f\u3070Swift\u306eXcode\u3068\u4f3c\u3066\u3044\u308b\u3002<\/p>\n<p>Config\u30d5\u30a1\u30a4\u30eb<\/p>\n<p>Model<\/p>\n<p>View<\/p>\n<h2>\u6700\u8fd1\u306eCake-php<\/h2>\n<p>\u6614\u306b\u6bd4\u3079\u308b\u3068\u4e0b\u706b\u306b\u306a\u3063\u3066\u3044\u308b\u3082\u306e\u306e\u3001\u73fe\u5728\u3067\u3082\u4f7f\u308f\u308c\u3066\u3044\u308b\u3002<br \/>\n\u4e16\u754c\u3067\u306f\u305d\u3053\u307e\u3067\u4f7f\u308f\u308c\u3066\u3044\u306a\u3044\u3082\u306e\u306e\u3001\u65e5\u672c\u56fd\u5185\u3067\u306f\u4eba\u6c17\u304c\u3042\u308b\u3002<br \/>\n\u7af6\u5408\u3059\u308bPHP\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3068\u3057\u3066\u306f\u3001Laravel\u306a\u3069\u304c\u3042\u308b\u3002<\/p>\n<h2>Cake-PHP\u306e\u5c0e\u5165<\/h2>\n<p>\u4f5c\u696d\u74b0\u5883\u306bLAMP\u74b0\u5883\u304c\u6574\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u305f\u3081\u306bComposer\u3092\u5c0e\u5165\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<p>\u3053\u308c\u306f\u3001PHP\u306b\u95a2\u3059\u308b\u5404\u7a2e\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u7ba1\u7406\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u306a\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305aCake-php\u3092\u5c0e\u5165\u3059\u308b\u306b\u3042\u305f\u3063\u3066\u5fc5\u8981\u3068\u306a\u308b\u3002<\/p>\n<p>\u3042\u308c\u3070\u30b9\u30e0\u30fc\u30ba\u3068\u3044\u3046\u304b\u3001\u4f8b\u3067\u306f\u307b\u307c\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u307b\u307c\u5fc5\u9808\u3068\u3044\u3063\u3066\u3082\u3044\u3044\u3060\u308d\u3046\u3002<\/p>\n<h3>\u5b9f\u969b\u306bMac\u306e\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306b\u5c0e\u5165\u3057\u3066\u307f\u305f\u7d50\u679c<\/h3>\n<p>Mac\u306e\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u4f7f\u3048\u308bApache\u306e\u74b0\u5883\u306bCakephp\u3092\u5c0e\u5165\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u307e\u305a\u306fComposer\u306e\u5c0e\u5165\u3060\u304c\u3001\u3053\u308c\u306f\u554f\u984c\u306a\u304f\u9032\u3080\u3002<\/p>\n<p>Cakephp\u3092Apache\u306e\u30c6\u30b9\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u307e\u3067\u79fb\u52d5\u3057\u3066\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3002<\/p>\n<p>\u5c0e\u5165\u306e\u6642\u70b9\u3067Warning\u304c\u51fa\u3066\u3044\u308b\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u3002<\/p>\n<p>\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u898b\u3066\u307f\u308b\u3068\u3001Cake-php\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u4e00\u5f0f\u751f\u6210\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<p>\u305d\u308c\u3067\u3001\u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3068\u3001500\u30a8\u30e9\u30fc\u3002<\/p>\n<p>\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u898b\u3066\u307f\u308b\u3068\u3001php-intl.so\u304c\u306a\u3044\u3068\u304b\u305d\u3046\u3044\u3046\u304b\u3093\u3058\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3044\u305f\u3002<\/p>\n<p>php\u306e\u62e1\u5f35\u6a5f\u80fd\u3067php-intl\u304c\u5fc5\u8981\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u5165\u308c\u3066\u307f\u308b\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001Hombrew\u3092\u4f7f\u3063\u3066\u3001brew \u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u8a66\u307f\u308b\u304c\u3001brew\u30b3\u30de\u30f3\u30c9\u3067\u6614\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u3066\u3044\u305f\u306e\u3060\u304c\u3001\u73fe\u5728\u306f\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3044\u308b\u3089\u3057\u3044\u3002<\/p>\n<p>Macports\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u3092\u4f7f\u3063\u305f\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u308b\u3089\u3057\u3044\u3002<\/p>\n<p>Homwbrew\u304c\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u3067Macports\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u3067\u3001\u4f55\u304c\u3069\u3046\u9055\u3046\u304b\u5206\u304b\u3089\u306a\u3044\u304c\u3001\u3084\u3063\u3066\u307f\u308b\u3068\u3068\u308a\u3042\u3048\u305aMacports\u306e\u307b\u3046\u3067\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u76f8\u5909\u308f\u3089\u305acakephp\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u76f4\u3057\u3066\u3082\u30a8\u30e9\u30fc\u3002<\/p>\n<p>\u30a8\u30e9\u30fc\u3092\u898b\u308b\u3068\u3001php-intl.dll\u304c\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3002<\/p>\n<p>\u8abf\u3079\u308b\u3068\u3001\u5834\u6240\u306b\u554f\u984c\u304c\u3042\u308b\u306e\u304c\u539f\u56e0\u3067\u79fb\u52d5\u3057\u305f\u3089\u3044\u3044\u3068\u3044\u3046\u3053\u3068\u306e\u3088\u3046\u306a\u306e\u3067\u3001php-intl.dll\u3092\u63a2\u3057\u3066\u307f\u308b\u3068\u3001\u3069\u3053\u306b\u3082\u306a\u3044\u3002<br \/>\n\u305d\u3082\u305d\u3082\u3001.dll\u30d5\u30a1\u30a4\u30eb\u306fWindows\u74b0\u5883\u3067\u5fc5\u8981\u306a\u3082\u306e\u3089\u3057\u304f\u3001Mac\u306eLinux\u30d9\u30fc\u30b9\u306e\u74b0\u5883\u3067\u306f\u4e0d\u8981\u3089\u3057\u3044\u306e\u3060\u304c\u3001\u3068\u306b\u304b\u304f\u52d5\u304b\u306a\u3044\u306e\u3067\u99c4\u76ee\u3002<\/p>\n<p>\u74b0\u5883\u69cb\u7bc9\u306e\u6642\u70b9\u3067\u3064\u307e\u3065\u3044\u3066\u3057\u307e\u3044\u3001\u304a\u624b\u4e0a\u3052\u72b6\u614b\u3060\u3063\u305f\u306e\u3060\u304c\u3001\u591a\u304f\u306e\u30b1\u30fc\u30b9\u3067XAMP\u307e\u305f\u306fMAMP\u74b0\u5883\u304c\u524d\u63d0\u306b\u306a\u3063\u3066\u3044\u305f\u306e\u3067\u3001MAMP\u74b0\u5883\u3092\u5165\u308c\u3066\u307f\u305f\u3068\u3053\u308d\u3001\u3042\u3063\u3055\u308a\u3068\u52d5\u3044\u305f\u3002<\/p>\n<p>\u203b\u6ce8<\/p>\n<p>MAMP\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u3001PHP\u306e\u52d5\u4f5c\u74b0\u5883\u3092\u3001MAMP\u306ePHP\u306b\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3002<\/p>\n<p><a href=\"https:\/\/qiita.com\/YoshikiNakamura\/items\/bcceaaa3d064a08233c1\">MAMP\u3068Composer\u3092\u4f7f\u3063\u305fCakePHP3.x\u306e\u30ed\u30fc\u30ab\u30eb\u958b\u767a\u74b0\u5883\u306e\u69cb\u7bc9<\/a><\/p>\n<p>MAMP\u74b0\u5883\u3067\u306f\u52d5\u3044\u3066\u3001\u30ed\u30fc\u30ab\u30eb\u306eMac\u74b0\u5883\u3067\u306f\u52d5\u304b\u306a\u304b\u3063\u305f\u3001\u305d\u306e\u9055\u3044\u306f\u4f55\u306a\u306e\u304b\u3088\u304f\u5206\u304b\u3089\u306a\u3044\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u52d5\u3044\u305f\u306e\u3067OK\u3002<\/p>\n<h3>\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u5b9f\u88c5\u3057\u3066\u307f\u308b<\/h3>\n<p>Cakephp\u306e\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>\u307e\u305a\u3001\u30e2\u30c7\u30eb\u306e\u90e8\u5206<\/p>\n<p>\u3053\u308c\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c6\u30fc\u30d6\u30eb\u3054\u3068\u306e\u898f\u7d04\u3092\u66f8\u3044\u3066\u3044\u308b\u3068\u3053\u308d\u3002<br \/>\n\u30c6\u30fc\u30d6\u30eb\u306e\u30ab\u30e9\u30e0\u3054\u3068\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u7b49\u3092\u5b9a\u7fa9\u3067\u304d\u308b\u3002<\/p>\n<p>\u30e2\u30c7\u30eb\u306b\u306f\u3001Entitity\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3001Table\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u3042\u308b\u3002<\/p>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f\u3001\u30b5\u30a4\u30c8\u306eURL\u306e\u547c\u3073\u51fa\u3057\u306b\u5bfe\u3057\u3066\u5b9f\u884c\u3055\u308c\u308b\u5b9f\u884c\u5185\u5bb9\u3068\u8003\u3048\u308c\u3070\u3044\u3044\u3002<\/p>\n<p>\/Controller\/\u25ef\u25efController.php<\/p>\n<p>\u306e\u5834\u5408\u3001\u30b5\u30a4\u30c8URL\/\u25ef\u25ef\u3067\u547c\u3073\u51fa\u3055\u308c\u308b\u3002<\/p>\n<p>\u30d3\u30e5\u30fc\u306f\u3001Template\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e2d\u3067\u3001URL\u306e\u968e\u5c64\u69cb\u9020\u3068\u540c\u3058\u3088\u3046\u306b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8a2d\u7f6e\u3057\u3066\u3001\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>\u62e1\u5f35\u5b50\u304cctp\u3068\u3044\u3046\u306e\u304c\u5909\u308f\u3063\u3066\u3044\u308b\u304c\u3001Smarty\u3068\u9055\u3063\u3066\u72ec\u7279\u306e\u8a18\u6cd5\u304c\u3042\u308b\u308f\u3051\u3067\u306f\u306a\u304f\u3001\u666e\u901a\u306ephp\u30d5\u30a1\u30a4\u30eb\u306b\u8fd1\u3044\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001php\u306e\u3054\u3061\u3083\u3054\u3061\u3083\u3057\u305f\u3084\u3084\u3053\u3057\u3044\u8a18\u8ff0\u90e8\u5206\u306fController\u3084Model\u306e\u90e8\u5206\u306b\u6620\u3063\u3066\u3044\u308b\u306e\u3067\u8a18\u8ff0\u306f\u6700\u4f4e\u9650\u306ephp\u306e\u90e8\u5206\u3060\u3051\u306b\u306a\u3063\u3066\u3044\u3066html\u304c\u30d9\u30fc\u30b9\u3068\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u4eba\u304c\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u898b\u3066\u4fee\u6b63\u3057\u305f\u308a\u5185\u5bb9\u3092\u7406\u89e3\u3057\u3084\u3059\u3044\u3068\u3044\u3046\u308f\u3051\u3060\u3002<\/p>\n<h2>Cakephp\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30bd\u30fc\u30b9\u306f\u3069\u3053\u306b\u3042\u308b\u304b<\/h2>\n<p>Cakephp\u3067\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u3001\u4ee5\u4e0b\u306e\u5834\u6240\u306b\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\/vender\/cakephp\/cakephp\/src\/<\/p>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">\/\/\u540d\u524d\u7a7a\u9593Cake\\ORM\u4ee5\u4e0b\u306eTable Registry\u30af\u30e9\u30b9\u3092\u7701\u7565\nuse Cake\\ORM\\TableRegistry;\n\n\/\/Table Registry\u30af\u30e9\u30b9\u306egetTableLocator\u30e1\u30bd\u30c3\u30c9\u306f\u3001'Cake\\ORM\\Locator\\TableLocator'\u30af\u30e9\u30b9\u306eget\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306fArticlesTable\u30af\u30e9\u30b9\u3092\u8fd4\u3057\u307e\u3059(Artices Table\u30af\u30e9\u30b9\u306f\u3001Table\u30af\u30e9\u30b9\u306e\u62e1\u5f35\u30af\u30e9\u30b9)\n\/\/Model\u2192Table\u306b\u4f5c\u6210\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u30af\u30e9\u30b9\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\n$articles = TableRegistry::getTableLocator()-&gt;get('Articles');\n\n\/\/Table class\u306efind()\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3057\u3066$query\u3078\u4ee3\u5165\n\/\/Articles\u30c6\u30fc\u30d6\u30eb\u306e\u884c\u3092\u5168\u3066select\u3067\u53d6\u308a\u51fa\u3059\n\/\/find\u306fselect\u3068\u57fa\u672c\u540c\u3058\n$query = $articles-&gt;find();\n\n\/\/\u53d6\u5f97\u3057\u305f\u884c\u304b\u3089query\u306etitle\u3092\u51fa\u529b\nforeach ($query as $row) {\n    \/\/\u884c\u306e\u9023\u60f3\u914d\u5217\u306etitle\u3092\u51fa\u529b\u3059\u308b\n    echo $row-&gt;title;\n}\n<\/pre>\n<p>\u305d\u308c\u305e\u308c\u306e\u30e1\u30bd\u30c3\u30c9\u3084\u30af\u30e9\u30b9\u306e\u610f\u5473\u3092\u7406\u89e3\u3057\u3088\u3046\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u6b63\u76f4\u826f\u304f\u308f\u304b\u3089\u306a\u3044\u306e\u3067\u3001\u304a\u307e\u3058\u306a\u3044\u7684\u306b\u899a\u3048\u3066\u304a\u3044\u305f\u307b\u3046\u304c\u3088\u3055\u305d\u3046\u3067\u3059\u3002<br \/>\n\uff08\u3080\u3057\u308d\u3001\u305d\u3046\u3044\u3046\u306e\u3092\u3044\u3061\u3044\u3061\u7406\u89e3\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u306e\u304c\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u3044\u3044\u3068\u3053\u308d\uff1f\uff09<\/p>\n<h2>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a<\/h2>\n<p>\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3057\u3066<\/p>\n<p>$connection-&gt;query($sql);<\/p>\n<p>\u3067sql\u3092\u5b9f\u884c\u3067\u304d\u308b\u304c\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u53d7\u3051\u4ed8\u3051\u305a\u3001\u307e\u305f\u3001sql\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u306e\u5371\u967a\u6027\u304c\u3042\u308b\u305f\u3081\u5371\u967a<\/p>\n<p>execute\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4f7f\u7528\u3092\u63a8\u5968\u3002\u30d7\u30ea\u30da\u30a2\u30fc\u30c9\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u304c\u4f7f\u7528\u3067\u304d\u308b\u3002<\/p>\n<p>$connection-&gt;execute(&#8216;SELECT * FROM articles WHERE id = :id&#8217;, [&#8216;id&#8217; =&gt; 1])-&gt;fetchAll(&#8216;assoc&#8217;);<\/p>\n<p>\u578b\u306b\u5bfe\u3057\u3066\u30d0\u30a4\u30f3\u30c9\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002<\/p>\n<p>$connection<br \/>\n-&gt;execute(<br \/>\n&#8216;SELECT * FROM articles WHERE created &gt;= :created&#8217;,<br \/>\n[&#8216;created&#8217; =&gt; new DateTime(&#8216;1 day ago&#8217;)],<br \/>\n[&#8216;created&#8217; =&gt; &#8216;datetime&#8217;]<br \/>\n)<br \/>\n-&gt;fetchAll(&#8216;assoc&#8217;);<\/p>\n<p>\u30d7\u30ea\u30da\u30a2\u30fc\u30c9\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u306f\u3001prepare\u3067\u6e96\u5099\u3057\u3066\u304b\u3089\u5225\u306e\u3068\u3053\u308d\u3067\u5f53\u3066\u306f\u3081\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002<\/p>\n<p>$stmt = $conn-&gt;prepare(<br \/>\n&#8216;SELECT * FROM articles WHERE published = ? AND created &gt; ?&#8217;<br \/>\n);<\/p>\n<p>\/\/ \u8907\u6570\u9805\u76ee\u306e\u30d0\u30a4\u30f3\u30c9<br \/>\n$stmt-&gt;bind(<br \/>\n[true, new DateTime(&#8216;2013-01-01&#8217;)],<br \/>\n[&#8216;boolean&#8217;, &#8216;date&#8217;]<br \/>\n);<\/p>\n<p>\/\/ \uff11\u9805\u76ee\u305a\u3064\u306e\u30d0\u30a4\u30f3\u30c9<br \/>\n$stmt-&gt;bindValue(1, true, &#8216;boolean&#8217;);<br \/>\n$stmt-&gt;bindValue(2, new DateTime(&#8216;2013-01-01&#8217;), &#8216;date&#8217;);<\/p>\n<p>newQuery()\u30e1\u30bd\u30c3\u30c9\u3067\u30af\u30a8\u30ea\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3057\u3066\u3001\u30af\u30a8\u30ea\u30d3\u30eb\u30c0\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002<\/p>\n<p>$connection<br \/>\n-&gt;newQuery()<br \/>\n-&gt;select(&#8216;*&#8217;)<br \/>\n-&gt;from(&#8216;articles&#8217;)<br \/>\n-&gt;where([&#8216;created &gt;&#8217; =&gt; new DateTime(&#8216;1 day ago&#8217;)], [&#8216;created&#8217; =&gt; &#8216;datetime&#8217;])<br \/>\n-&gt;order([&#8216;title&#8217; =&gt; &#8216;DESC&#8217;])<br \/>\n-&gt;execute()<br \/>\n-&gt;fetchAll(&#8216;assoc&#8217;);<\/p>\n<p>connection\u30aa\u30d7\u30b8\u30a7\u30af\u30c8\u304b\u3089\u3001insert\u6587\u3068update\u3001delete\u6587\u3092\u5b9f\u884c\u3067\u304d\u308b<\/p>\n<p>$connection-&gt;insert(&#8216;articles&#8217;, [<br \/>\n&#8216;title&#8217; =&gt; &#8216;A New Article&#8217;,<br \/>\n&#8216;created&#8217; =&gt; new DateTime(&#8216;now&#8217;)<br \/>\n], [&#8216;created&#8217; =&gt; &#8216;datetime&#8217;]);<\/p>\n<p>$connection-&gt;update(&#8216;articles&#8217;, [&#8216;title&#8217; =&gt; &#8216;New title&#8217;], [&#8216;id&#8217; =&gt; 10]);<\/p>\n<p>use Cake\\Datasource\\ConnectionManager;<br \/>\n$connection = ConnectionManager::get(&#8216;default&#8217;);<\/p>\n<p>\u53d6\u5f97\u3057\u305f\u884c\u3092\u3092\u914d\u5217\u306b\u8aad\u307f\u8fbc\u3080<\/p>\n<p>\/\/ \uff11\u884c\u8aad\u307f\u8fbc\u3080<br \/>\n$row = $stmt-&gt;fetch(&#8216;assoc&#8217;);<\/p>\n<p>\/\/ \u5168\u884c\u3092\u8aad\u307f\u8fbc\u3080<br \/>\n$rows = $stmt-&gt;fetchAll(&#8216;assoc&#8217;);<\/p>\n<p>\u884c\u6570\u3092\u53d6\u5f97\u3059\u308b<\/p>\n<p>$rowCount = count($stmt);<br \/>\n$rowCount = $stmt-&gt;rowCount();<\/p>\n<p>\u30a8\u30e9\u30fc\u60c5\u5831\u306e\u53d6\u5f97<\/p>\n<p>$code = $stmt-&gt;errorCode();<br \/>\n$info = $stmt-&gt;errorInfo();<\/p>\n<p>\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u5229\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089begin\u3068commit\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u5229\u7528\u3067\u304d\u308b\u3002<\/p>\n<p>$conn-&gt;begin();<br \/>\n$conn-&gt;execute(&#8216;UPDATE articles SET published = ? WHERE id = ?&#8217;, [true, 2]);<br \/>\n$conn-&gt;execute(&#8216;UPDATE articles SET published = ? WHERE id = ?&#8217;, [false, 4]);<br \/>\n$conn-&gt;commit();<\/p>\n<h2>\u547d\u540d\u898f\u5247<\/h2>\n<p>cakephp\u3067\u306f\u3001\u57fa\u672c\u7684\u306b\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3001\u30e2\u30c7\u30eb\u3001\u30d3\u30e5\u30fc\u306b\u547d\u540d\u898f\u5247\u304c\u3042\u308a\u3001\u305d\u308c\u306b\u5f93\u3063\u3066\u4f5c\u6210\u3057\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<p>\u30e2\u30c7\u30eb\u2194DB\u30c6\u30fc\u30d6\u30eb\u540d\u306b\u5bfe\u5fdc<\/p>\n<p>DB\u306e\u30c6\u30fc\u30d6\u30eb\u540d\u300carticles\u300d\u306e\u5834\u5408\u3001\u30e2\u30c7\u30eb\u306f\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u5bfe\u5fdc\u3057\u3066\u4f5c\u6210\u3055\u308c\u308b\u3002<\/p>\n<p>\/Model\/Entity\/Article.php<\/p>\n<p>\/Model\/Table\/ArticleTable.php<\/p>\n<p>URL\u2192\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u540d(+\u30e1\u30bd\u30c3\u30c9)\u3001\u30d3\u30e5\u30fc\u540d\u306b\u5bfe\u5fdc<\/p>\n<p>http:\/\/\u25ef\u25ef\u25ef\/articles\/<\/p>\n<p>\/src\/Controller\/ArticlesController.php<\/p>\n<p>index()\u3000\u5185\u3092\u5b9f\u884c<\/p>\n<p>http:\/\/\u25ef\u25ef\u25ef\/articles\/add\/<\/p>\n<p>\/src\/Controller\/ArticlesController.php<\/p>\n<p>add()\u3000\u5185\u3092\u5b9f\u884c<\/p>\n<p>URL\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u95a2\u4fc2\u306f\u81ea\u52d5\u7684\u306b\u547d\u540d\u898f\u5247\u3067\u6c7a\u5b9a\u3057\u307e\u3059\u304c\u3001\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u306f\u3001\/config\/routes.php\u3000\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3067\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u5909\u66f4\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cake-php\u306f\u3001MVC\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u308bPHP\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af MVC\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3068\u306f\u3001Model\u3001View\u3001Conroller\u3067\u5206\u96e2\u3055\u308c\u3066\u3044\u308b\u3001\u3044\u308f\u3070Swift\u306eXcode\u3068\u4f3c\u3066\u3044\u308b\u3002 Config\u30d5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165,131],"tags":[],"class_list":["post-9837","post","type-post","status-publish","format-standard","hentry","category-cakephp","category-131"],"_links":{"self":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9837"}],"version-history":[{"count":0,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9837\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}