{"id":21341,"date":"2020-05-18T08:36:18","date_gmt":"2020-05-17T23:36:18","guid":{"rendered":"https:\/\/kimassi.net\/zak\/?p=21341"},"modified":"2020-05-24T13:34:23","modified_gmt":"2020-05-24T04:34:23","slug":"%e3%80%8c%e6%b0%97%e3%81%a5%e3%81%91%e3%81%b0%e3%83%97%e3%83%ad%e4%b8%a6%e3%81%bfphp%e3%80%8d%e3%81%a7php%e3%81%ae%e5%8b%89%e5%bc%b7%e3%82%92%e5%86%8d%e9%96%8b","status":"publish","type":"post","link":"https:\/\/kimassi.net\/zak\/?p=21341","title":{"rendered":"\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u300d\u3067PHP\u306e\u52c9\u5f37\u3092\u518d\u958b"},"content":{"rendered":"<p><span style=\"color: #ff0000;\"><strong>2020\u5e745\u670817\u65e5<\/strong><\/span><\/p>\n<p>PHP\u3067\u91d1\u6ca2\u306e\u5b89\u3044\u5bbf\u306e\u4e00\u89a7\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6539\u826f\u3057\u305f\u306e\u3092\u6a5f\u306b\u3001PHP\u306e\u52c9\u5f37\u3092\u518d\u958b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u8cfc\u5165\u3057\u305f\u306e\u306f\u3001\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3067\u3059\u3002\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u306b\u306f\u6539\u8a02\u7248\u3082\u51fa\u7248\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u5185\u5bb9\u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u5897\u5f37\u304c\u3042\u308b\u3060\u3051\u3067\u3001\u307b\u3068\u3093\u3069\u540c\u3058\u5185\u5bb9\u3067\u3059\u3002<\/p>\n<p>\u300cPHP\u306e\u7d75\u672c\u300d\u3067PHP\u306e\u57fa\u790e\u3092\u52c9\u5f37\u3057\u3001\u300c\u516c\u958bAPI\u6d3b\u7528\u30ac\u30a4\u30c9 (I\u30fbO BOOKS)\u300d\u3067\u697d\u5929\u30c8\u30e9\u30d9\u30eb\u7a7a\u5ba4\u691c\u7d22API\u3092\u4f7f\u3063\u3066\u306e\u5b89\u3044\u5bbf\u4e00\u89a7\u306e\u8868\u793a\u306b\u4f7f\u3044\u3001\u300c\u3088\u304f\u308f\u304b\u308bPHP\u306e\u6559\u79d1\u66f8\u3000 \u305f\u306b\u3050\u3061 \u307e\u3053\u3068\u300d\u300cBootstrap\u30d5\u30a1\u30fc\u30b9\u30c8\u30ac\u30a4\u30c9\u300d\u3067\u30cd\u30c3\u30c8\u63b2\u793a\u677f\u3092\u4f5c\u308a\u3001\u6b8b\u308a\u306ePHP\u306e\u4e3b\u306a\u5229\u7528\u7528\u9014\u306f\u304a\u5e97\u306e\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u30ab\u30fc\u30c8\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u305d\u308c\u3067\u3001\u304a\u5e97\u306e\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0\u30ab\u30fc\u30c8\u3092\u4f5c\u308b\u306e\u306b\u5f79\u7acb\u3064\u672c\u3092\u63a2\u3057\u3066\u898b\u3064\u3051\u305f\u306e\u304c\u3001\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3067\u3059\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u8aad\u3093\u3067\u307f\u307e\u3057\u305f\u304c\u3001\u3068\u3066\u3082\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n<p>\u540c\u3058\u8457\u8005\u306e\u300c\u3044\u304d\u306a\u308a\u306f\u3058\u3081\u308bPHP~\u30ef\u30af\u30ef\u30af\u30fb\u30c9\u30ad\u30c9\u30ad\u306e\u5165\u9580\u6559\u5ba4~\u3000\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3082\u521d\u5fc3\u8005\u7528\u306b\u306f\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u8cfc\u5165\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>1\u5e74\u306e\u30d6\u30e9\u30f3\u30af\u3067PHP\u306e\u57fa\u790e\u3082\u3001\u3059\u3063\u304b\u308a\u5fd8\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u826f\u3044\u6a5f\u4f1a\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>2020\u5e745\u670819\u65e5<\/strong><\/span><\/p>\n<p>\u300c\u3044\u304d\u306a\u308a\u306f\u3058\u3081\u308bPHP~\u30ef\u30af\u30ef\u30af\u30fb\u30c9\u30ad\u30c9\u30ad\u306e\u5165\u9580\u6559\u5ba4~\u3000\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3092\u8aad\u3093\u3067\u307f\u307e\u3057\u305f\u3002<br \/>\n2011\u5e74\u306b\u66f8\u304b\u308c\u305f\u672c\u306a\u306e\u3067\u3001WindowsXP\u3001WindowsVista\u3001Windows7\u306a\u3069\u3057\u304b\u306a\u3044\u6642\u4ee3\u306a\u306e\u3067\u3001\u3055\u3059\u304c\u306b\u5185\u5bb9\u306f\u53e4\u3044\u3067\u3059\u3002\u305d\u308c\u3092\u8003\u616e\u3057\u3066\u3082\u3001\u53c2\u8003\u306b\u306a\u308b\u826f\u66f8\u3060\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\nPHP\u306e\u672c\u5f53\u306b\u57fa\u672c\u7684\u306a\u90e8\u5206\u306f\u8a73\u7d30\u306b\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u304c\uff08\u305d\u3046\u3044\u3046\u306e\u306f\u300cPHP\u306e\u7d75\u672c\u300d\u304c\u304a\u5968\u3081\uff09PHP\u3067MySQL\u3084\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u3046\u969b\u306e\u57fa\u672c\u7684\u306a\u90e8\u5206\u304c\u5224\u308a\u3084\u3059\u304f\u30d4\u30c3\u30af\u30a2\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u826f\u3044\u3067\u3059\u3002<br \/>\n\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9\u304c\u4ed8\u3044\u3066\u3044\u308b\u3068\u5b9f\u969b\u306b\u52d5\u4f5c\u3059\u308b\u306e\u304b\u78ba\u8a8d\u51fa\u6765\u3066\u826f\u3044\u306e\u306b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>2020\u5e745\u670820\u65e5<\/strong><\/span><\/p>\n<p>\u300c\u3044\u304d\u306a\u308a\u306f\u3058\u3081\u308bPHP~\u30ef\u30af\u30ef\u30af\u30fb\u30c9\u30ad\u30c9\u30ad\u306e\u5165\u9580\u6559\u5ba4~\u3000\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3092\u8aad\u3093\u3067\u3001PHP\u3067\u7406\u89e3\u304c\u6d45\u3044\u5f31\u70b9\u304c\u3001\u5224\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p><span style=\"color: #ff0000;\">1<\/span>.\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300c\u2019\u300d\u3068\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u300c&#8221;\u300d\u306e\u4f7f\u3044\u65b9\u306e\u9055\u3044<br \/>\n<span style=\"color: #ff0000;\">2<\/span>.&lt;form&gt; &lt;\/form&gt;\u304b\u3089\u9001\u3089\u308c\u3066\u304d\u305f\u914d\u5217\u5909\u6570\uff08\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30b3\u30fc\u30c9\u4e2d\u3069\u3053\u304b\u3089\u3067\u3082\u4f7f\u7528\u53ef\uff09<br \/>\n$_POST[&#8216;<span style=\"color: #0000ff;\">\u5909\u6570<\/span>&#8216;]<br \/>\n<span style=\"color: #ff0000;\">3<\/span>.HTML\u306e\u5165\u529b\u30fb\u9001\u4fe1\u30d5\u30a9\u30fc\u30e0<br \/>\n&lt;form method=&#8221;post&#8221; action=&#8221;<span style=\"color: #0000ff;\">submit\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u6642\u306e\u98db\u3073\u5148<\/span>&#8220;&gt;<br \/>\n&lt;input type=&#8221;submit&#8221; value=&#8221;OK&#8221;&gt;<br \/>\n&lt;\/form&gt;<br \/>\n<span style=\"color: #ff0000;\">4<\/span>.&lt;form&gt; &lt;\/form&gt;\u5185\u3067\u30d5\u30a9\u30fc\u30e0\u306e\u9001\u4fe1\u6642\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u898b\u305f\u308a\u5909\u66f4\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u30c7\u30fc\u30bf\u306e\u6271\u3044<br \/>\n&lt;input name=&#8221;<span style=\"color: #0000ff;\">\u5165\u529b\u6b04\u306e\u540d\u524d<\/span>&#8221; type=&#8221;hidden&#8221; value=&#8221;<span style=\"color: #0000ff;\">\u6e21\u3057\u305f\u3044\u30c7\u30fc\u30bf<\/span>&#8220;&gt;<br \/>\n\u6e21\u3057\u305f\u3044\u30c7\u30fc\u30bf\u304c\u5909\u6570\u306a\u3089<br \/>\n&lt;input name=&#8221;<span style=\"color: #0000ff;\">\u5165\u529b\u6b04\u306e\u540d\u524d<\/span>&#8221; type=&#8221;hidden&#8221; value=&#8221;&#8216;.<span style=\"color: #0000ff;\">\u5909\u6570<\/span>.'&#8221;&gt;<br \/>\n<span style=\"color: #ff0000;\">5<\/span>.SQL\u306e\u5165\u529b<br \/>\nINSERT INTO <span style=\"color: #0000ff;\">\u30c6\u30fc\u30d6\u30eb\u540d<\/span> (<span style=\"color: #0000ff;\">\u30d5\u30a3\u30fc\u30eb\u30c9\u540d1<\/span>\u3001<span style=\"color: #0000ff;\">\u30d5\u30a3\u30fc\u30eb\u30c9\u540d2<\/span>\u3001<span style=\"color: #0000ff;\">\u30d5\u30a3\u30fc\u30eb\u30c9\u540d2<\/span>) VALUES (&#8220;<span style=\"color: #0000ff;\">\u30c7\u30fc\u30bf1<\/span>&#8220;,&#8221;<span style=\"color: #0000ff;\">\u30c7\u30fc\u30bf2<\/span>&#8220;,&#8221;<span style=\"color: #0000ff;\">\u30c7\u30fc\u30bf3<\/span>&#8220;)<br \/>\n<span style=\"color: #ff0000;\">6<\/span>.\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a<br \/>\n\u300c\u3044\u304d\u306a\u308a\u306f\u3058\u3081\u308bPHP~\u30ef\u30af\u30ef\u30af\u30fb\u30c9\u30ad\u30c9\u30ad\u306e\u5165\u9580\u6559\u5ba4~\u3000\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3067\u306f<br \/>\n$dsn=&#8217;mysql:host=<span style=\"color: #0000ff;\">\u30db\u30b9\u30c8\u306e\u30a2\u30c9\u30ec\u30b9<\/span>;dbname=<span style=\"color: #0000ff;\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d<\/span>&#8216;;<br \/>\n$user = &#8216;<span style=\"color: #0000ff;\">\u30e6\u30fc\u30b6\u30fc\u540d<\/span>&#8216;;<br \/>\n$password =&#8217;<span style=\"color: #0000ff;\">\u30d1\u30b9\u30ef\u30fc\u30c9<\/span>&#8216;;<br \/>\n$dbh = new PDO($dsn,$user,$password);<br \/>\n$dbh -&gt;query(&#8216;SET NAMES utf8&#8217;);<br \/>\n\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001<br \/>\n$dsn=&#8217;mysql:host=<span style=\"color: #0000ff;\">\u30db\u30b9\u30c8\u306e\u30a2\u30c9\u30ec\u30b9<\/span>;dbname=<span style=\"color: #0000ff;\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d<\/span>&#8216;;<br \/>\n$db = new PDO($dsn, &#8216;<span style=\"color: #0000ff;\">\u30e6\u30fc\u30b6\u30fc\u540d<\/span>&#8216;, &#8216;<span style=\"color: #0000ff;\">\u30d1\u30b9\u30ef\u30fc\u30c9<\/span>&#8216;);<br \/>\n\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n<span style=\"color: #ff0000;\">7<\/span>.\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a8\u30f3\u30b8\u30f3\u306bSQL\u6587\u3067\u6307\u4ee4\u3092\u51fa\u3059<br \/>\n\u300c\u3044\u304d\u306a\u308a\u306f\u3058\u3081\u308bPHP~\u30ef\u30af\u30ef\u30af\u30fb\u30c9\u30ad\u30c9\u30ad\u306e\u5165\u9580\u6559\u5ba4~\u3000\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3067\u306f<br \/>\n$sql=&#8217;<span style=\"color: #0000ff;\">SQL\u6587<\/span>&#8216;;<br \/>\n$stmt =$db-&gt;prepare($sql);<br \/>\n$stmt-&gt;execute();<br \/>\n$result = $stmt-&gt;fetch(PDO::FETCH_ASSOC); <span style=\"color: #339966;\">\/\/$stmt\u304b\u3089\uff11\u3064\u305a\u3064\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u3060\u3059<\/span><br \/>\n\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001<br \/>\n$stmt =$db-&gt;query(&#8220;<span style=\"color: #0000ff;\">SQL\u6587<\/span>&#8220;);<br \/>\n$result = $stmt-&gt;fetch(); <span style=\"color: #339966;\">\/\/$stmt\u304b\u3089\uff11\u3064\u305a\u3064\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u3060\u3059<\/span><br \/>\n\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n<span style=\"color: #ff0000;\">\uff18<\/span>.\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u767b\u9332\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u51fa\u3059<br \/>\nSELECT * FROM \u30c6\u30fc\u30d6\u30eb\u540d WHERE \u6761\u4ef6<br \/>\n<span style=\"color: #ff0000;\">\uff19<\/span>.\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u5168\u90e8\u53d7\u3051\u53d6\u308b<br \/>\n$sql = &#8216;SELECT * FROM \u30c6\u30fc\u30d6\u30eb\u540d WHERE 1&#8217;;<br \/>\n$stmt = dbh-&gt;prepare($sql);<br \/>\n$stml-&gt;execute();<br \/>\n<span style=\"color: #ff0000;\">\uff11\uff10<\/span>.$stmt\u304b\u3089\u30c7\u30fc\u30bf\u3092\u9806\u756a\u306b\uff11\u3064\u305a\u3064\u53d6\u308a\u51fa\u3059<br \/>\n$rec = $stmt-&gt;fetch(PDO::FETCH_ASSOC);<br \/>\n\u305d\u308c\u3092\u8868\u793a\u3059\u308b\u306e\u306f<br \/>\nprint $rec[&#8216;\u30d5\u30a3\u30fc\u30eb\u30c9\u540d&#8217;];<br \/>\n\u3059\u3079\u3066\u306e\u30da\u30fc\u30b8\u3092\u51e6\u7406\u3059\u308b\u306b\u306f<br \/>\nwhile(1)<br \/>\n{<br \/>\n$rec = $stmt-&gt;fetch(PDO::FETCH_ASSOC);<br \/>\nif($rec==false)<br \/>\n{<br \/>\nbreak;<br \/>\n}<br \/>\nprint $rec[&#8216;\u30d5\u30a3\u30fc\u30eb\u30c9\u540d&#8217;];<br \/>\n}<br \/>\n$dbh = null;<\/p>\n<p>\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u6539\u8a02\u7248\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3082\u8cfc\u5165\u3057\u307e\u3057\u305f\u3002<br \/>\n\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3068\u6bd4\u8f03\u3057\u3066\u3001\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u65e7\u7248\u306e\u307b\u3046\u304c\u5fc5\u8981\u306a\u3051\u308c\u3070\u3001\u30e1\u30eb\u30ab\u30ea\u3067\u58f2\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002\u5b89\u304f\u8cb7\u3063\u305f\u306e\u3067\u3001\u307b\u3068\u3093\u3069\u6301\u3061\u51fa\u3057\u306a\u3057\u3067\u58f2\u308c\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2020\u5e745\u670817\u65e5 PHP\u3067\u91d1\u6ca2\u306e\u5b89\u3044\u5bbf\u306e\u4e00\u89a7\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6539\u826f\u3057\u305f\u306e\u3092\u6a5f\u306b\u3001PHP\u306e\u52c9\u5f37\u3092\u518d\u958b\u3057\u307e\u3057\u305f\u3002 \u8cfc\u5165\u3057\u305f\u306e\u306f\u3001\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u3067\u3059\u3002\u300c\u6c17\u3065\u3051\u3070\u30d7\u30ed\u4e26\u307fPHP\u3000\u8c37\u85e4\u8ce2\u4e00\u300d\u306b\u306f\u6539\u8a02\u7248\u3082\u51fa\u7248\u3055 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[48,17,19],"tags":[],"class_list":["post-21341","post","type-post","status-publish","format-standard","hentry","category-php","category-17","category-19"],"_links":{"self":[{"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=\/wp\/v2\/posts\/21341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21341"}],"version-history":[{"count":18,"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=\/wp\/v2\/posts\/21341\/revisions"}],"predecessor-version":[{"id":21395,"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=\/wp\/v2\/posts\/21341\/revisions\/21395"}],"wp:attachment":[{"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kimassi.net\/zak\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}