{"id":219,"date":"2016-11-11T10:47:54","date_gmt":"2016-11-11T01:47:54","guid":{"rendered":"http:\/\/www.dogrow.net\/php\/?p=219"},"modified":"2017-09-01T17:13:35","modified_gmt":"2017-09-01T08:13:35","slug":"blog15","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/php\/blog15\/","title":{"rendered":"(15) mysqli\u3067\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3"},"content":{"rendered":"<h1 class=my_h1>\u3084\u3063\u3066\u307f\u305f\u3044\u3053\u3068<\/h1>\n<p>\u5148\u306b\u8a18\u3057\u305f\u300c<a href=\"http:\/\/www.dogrow.net\/php\/?p=200\">(14) SQLite\u3067\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3<\/a>\u300d\u3068\u540c\u3058\u3053\u3068\u3092MySQL\u3067\u3082\u3084\u3063\u3066\u307f\u308b\u3002<\/p>\n<p>\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u3001MySQL\u306eDB\u306f <span class=\"my_fs_big5 my_fc_red\">InnoDB<\/span> \u3067\u4f5c\u308b\u3053\u3068\u3002<br \/>\n\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\u3001<span class=myr>MyISAM<\/span> \u3092\u9078\u3093\u3067\u3082\u3088\u3044\u3002<br \/>\n\u4e21\u8005\u306e\u30e1\u30ab\u30cb\u30ba\u30e0\u306e\u9055\u3044\u306f<a href=\"https:\/\/www.google.co.jp\/search?q=InnoDB+%E3%81%A8myisam&#038;ie=utf-8&#038;oe=utf-8&#038;client=firefox-b&#038;gfe_rd=cr&#038;ei=NSYlWOm_LLTf8AfF34GgBQ\" target=_blank>\u30b0\u30b0\u308b<\/a>\u3068\u60c5\u5831\u304c\u5f97\u3089\u308c\u308b\u3002<\/p>\n<h1 class=my_h>\u30d7\u30ed\u30b0\u30e9\u30e0\u4f5c\u6210<\/h1>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n  \/\/ DB\u63a5\u7d9a\r\n  $cMySQL = new mysqli(&quot;localhost&quot;, DB_USER, DB_PW, DB_NAME);\r\n  if($cMySQL === FALSE){\r\n    goto tagEND;\r\n  }\r\n  \/\/ Transaction\u958b\u59cb\r\n  if($cMySQL-&gt;begin_transaction() === FALSE){\r\n    goto tagEND;\r\n  }\r\n  \/\/ \u30c7\u30fc\u30bf\u633f\u5165\uff03\uff11\r\n  $sql = &quot;INSERT INTO `user` (`id`,`name`,`age`) VALUES(NULL,'Kimoto','41');&quot;;\r\n  if($cMySQL-&gt;query($sql) === FALSE){\r\n    $cMySQL-&gt;rollback(); goto tagEND;\r\n  }\r\n  \/\/ \u30c7\u30fc\u30bf\u633f\u5165\uff03\uff12\r\n  $sql = &quot;INSERT INTO `score` (`id`,`get`,`lost`) VALUES(NULL,'11','18','2');&quot;;\r\n  if($cMySQL-&gt;query($sql) === FALSE){\r\n    $cMySQL-&gt;rollback(); goto tagEND;\r\n  }\r\n  \/\/ Transaction\u7d42\u4e86\uff08COMMIT\uff09\r\n  if($cMySQL-&gt;commit() === FALSE){\r\n    $cMySQL-&gt;rollback(); goto tagEND;\r\n  }\r\ntagEND:\r\n  if($cMySQL){\r\n    $cMySQL-&gt;close();\r\n  }\r\n<\/pre>\n<h1 class=my_h>PHP ver.5.5\u4ee5\u524d\u306e\u5834\u5408<\/h1>\n<p>\u4e0a\u8a18\u306e\u30e9\u30c3\u30d1\u30fc\u95a2\u6570\u306f\u4f7f\u3048\u306a\u3044\u3002SQL\u30b3\u30de\u30f3\u30c9\u3092\u76f4\u306b\u6253\u3064\u3053\u3068\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n  $cMySQL-&gt;query(&quot;SET AUTOCOMMIT=0;&quot;);\r\n  $cMySQL-&gt;query(&quot;BEGIN;&quot;);\r\n    :\r\n  $cMySQL-&gt;query(&quot;COMMIT;&quot;);\r\n    or\r\n  $cMySQL-&gt;query(&quot;ROLLBACK;&quot;);\r\n<\/pre>\n<hr class=my_hr_bottom>\n","protected":false},"excerpt":{"rendered":"<p>\u3084\u3063\u3066\u307f\u305f\u3044\u3053\u3068 \u5148\u306b\u8a18\u3057\u305f\u300c(14) SQLite\u3067\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u300d\u3068\u540c\u3058\u3053\u3068\u3092MySQL\u3067\u3082\u3084\u3063\u3066\u307f\u308b\u3002 \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u3001MySQL\u306eDB\u306f InnoDB \u3067\u4f5c\u308b\u3053\u3068\u3002 \u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u308f\u306a\u3044\u5834\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/php\/blog15\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-219","post","type-post","status-publish","format-standard","hentry","category-mysql"],"views":2417,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/comments?post=219"}],"version-history":[{"count":34,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/219\/revisions"}],"predecessor-version":[{"id":774,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/posts\/219\/revisions\/774"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/media?parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/php\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}