{"id":2024,"date":"2016-09-28T05:34:12","date_gmt":"2016-09-27T20:34:12","guid":{"rendered":"http:\/\/appsweets.net\/blog\/?p=2024"},"modified":"2016-09-28T05:34:12","modified_gmt":"2016-09-27T20:34:12","slug":"abeanibot-introduced-2","status":"publish","type":"post","link":"https:\/\/appsweets.net\/blog\/2016\/09\/28\/abeanibot-introduced-2\/","title":{"rendered":"Abeanibot introduced #2"},"content":{"rendered":"<div class=\"db9cc8cdb64025d13c1cc9dad0a0e262\" data-index=\"1\" style=\"float: left; margin: 16px 16px 16px 0;\">\n<script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-5825700137064158\";\r\n\/* 250sq, appsweets-blog *\/\r\ngoogle_ad_slot = \"4837931762\";\r\ngoogle_ad_width = 250;\r\ngoogle_ad_height = 250;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script>\n<\/div>\n<p>\u524d\u306e<a href=\"http:\/\/appsweets.net\/blog\/2016\/09\/26\/abeanibot-introduced\/\">\u8a18\u4e8b<\/a>\u3067\u3001<\/p>\n<blockquote><p>\u691c\u7d22\u7d50\u679c\u3092\u30ed\u30fc\u30ab\u30eb\u306b\u4fdd\u6301\u3057\u3066\u3042\u308b sqlite \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u7167\u5408\u3059\u308b\u3002\u65b0\u3057\u3044\u3082\u306e\u304c\u3042\u308c\u3070\u305d\u308c\u3092\u30c4\u30a4\u30fc\u30c8\u3059\u308b\n<\/p><\/blockquote>\n<p>\u3068\u66f8\u3044\u305f\u3002\u3053\u3053\u306e\u3084\u308a\u65b9\u306f sqlite \u306a\u3089\u3067\u306f\u306e\u3082\u306e\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u4e00\u5fdc\u30e1\u30e2\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>\u666e\u901a\u306b\u8003\u3048\u308b\u3068\u3001\u756a\u7d44 A \u304c\u65e2\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u3042\u308b\u304b\u3092\u7167\u5408\u3057\u3001\u305d\u306e\u7d50\u679c\u306b\u3088\u3063\u3066\u51e6\u7406\u3092\u632f\u308a\u5206\u3051\u308b\u306b\u306f<\/p>\n<ul>\n<li>[cci]select * from program where name=:A[\/cci] \u3059\u308b<\/li>\n<li>\u30ec\u30b3\u30fc\u30c9\u30bb\u30c3\u30c8\u304c\u884c\u3092\u8fd4\u3055\u306a\u304b\u3063\u305f\u3089 [cci]insert into program (name) values (:A)[\/cci] \u3059\u308b\u3002\u305d\u3057\u3066\u30c4\u30a4\u30fc\u30c8\u3059\u308b\n<\/ul>\n<p>\u3068\u30011 \u756a\u7d44\u306b\u3064\u304d 2 \u56de\u30af\u30a8\u30ea\u3092\u767a\u884c\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002\u3053\u308c\u306f\u7121\u99c4\u306a\u611f\u3058\u304c\u3059\u308b\u306e\u3067\u3001\u4f8b\u306e sqlite \u5074\u306e\u95a2\u6570\u306e\u5b9f\u4f53\u3092 php \u3067\u5b9f\u88c5\u3067\u304d\u308b\u6a5f\u80fd\u3092\u4f7f\u3046\u3002<\/p>\n<p><code lang=\"php\"><br \/>\n$db = new SQLite3(\"program.db\");<br \/>\n$db->createFunction(\"php_name\", __NAMESPACE__ . \"\\\\phpName\");<\/p>\n<p>$insertedNames = [];<\/p>\n<p>function phpName ($name) {<br \/>\n    global $insertedNames;<br \/>\n    $insertedNames[$name] = 1;<br \/>\n    return $name;<br \/>\n}<br \/>\n<\/code><br \/>\n\u3053\u3093\u306a\u611f\u3058\u306b\u3057\u3068\u3044\u3066\u3001[cci]insert or ignore into program (name) values (php_name(:A))[\/cci] \u3068\u3059\u308b\u3068\u3001\u756a\u7d44 A \u304c\u30c6\u30fc\u30d6\u30eb\u306b\u5b58\u5728\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u6642\u306e\u307f php_name \u95a2\u6570\u304c\u547c\u3070\u308c\u3001\u305d\u3057\u3066\u884c\u304c\u8ffd\u52a0\u3055\u308c\u308b\u3002php_name \u95a2\u6570\u81ea\u4f53\u306f\u4f55\u3082\u526f\u4f5c\u7528\u3092\u3082\u305f\u3089\u3055\u306a\u3044\u306e\u3060\u304c\u3053\u306e\u6642 PHP \u5074\u306b\u5236\u5fa1\u304c\u3044\u3063\u305f\u3093\u79fb\u308b\u306e\u3067\u3001\u305d\u3053\u3067\u9069\u5f53\u306a\u3082\u306e\u306b\u899a\u3048\u3066\u304a\u304f\u3002\u3053\u3046\u3059\u308b\u3068 1 \u756a\u7d44\u306b\u3064\u304d 1 \u30af\u30a8\u30ea\u3067\u6e08\u3080\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<p>\u3068\u3053\u308d\u3067 createFunction \u306e\u7b2c 2 \u5f15\u6570\u306b\u306f PHP \u5074\u306e\u95a2\u6570\u3092\u6307\u5b9a\u3059\u308b\u3002PHP \u3067\u95a2\u6570\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6307\u3057\u793a\u3059\u65b9\u6cd5\u3068\u3057\u3066\u306f\u3001\u95a2\u6570\u540d\u306e\u6587\u5b57\u5217\u3001[cci]array([$this object], [method name string])[\/cci] \u306e\u3088\u3046\u306a\u914d\u5217\u3001\u30af\u30e9\u30b9\u540d\u3092\u524d\u7f6e\u3057\u305f\u9759\u7684\u30e1\u30bd\u30c3\u30c9\u540d\u6587\u5b57\u5217\u306a\u3069\u304c\u6bb5\u968e\u7684\u306b\u8ffd\u52a0\u3055\u308c\u3066\u304d\u305f\u3002\u52a0\u3048\u3066\u6700\u8fd1\u306e PHP \u3067\u306f function \u30ea\u30c6\u30e9\u30eb\u305d\u306e\u3082\u306e\u3082\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\uff08\u3053\u308c\u306f Closure \u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u5b9f\u4f53\u3060\uff09\u3002<\/p>\n<p>\u3053\u306e\u6bb5\u968e\u7684\u3068\u3044\u3046\u306e\u304c\u30df\u30bd\u3067\u3001sqlite3::createFunction \u306f\u6700\u3082\u521d\u6b69\u7684\u306a\u95a2\u6570\u540d\u6587\u5b57\u5217\u3057\u304b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u3063\u307d\u3044\u306e\u3067\u3042\u308b\uff08\u304b\u308d\u3046\u3058\u3066\u3001\u540d\u524d\u7a7a\u9593\u306f\u8a8d\u8b58\u3059\u308b\u304c\uff09\u3002\u3053\u306e\u3078\u3093\u306e\u300c\u3046\u3046n\u2026\u300d\u3055\u304c\u307e\u3042 PHP \u3089\u3057\u3055\u306a\u306e\u3060\u304c\u3002<\/p>\n<div class=\"db9cc8cdb64025d13c1cc9dad0a0e262\" data-index=\"1\" style=\"float: left; margin: 16px 16px 16px 0;\">\n<script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-5825700137064158\";\r\n\/* 250sq, appsweets-blog *\/\r\ngoogle_ad_slot = \"4837931762\";\r\ngoogle_ad_width = 250;\r\ngoogle_ad_height = 250;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script>\n<\/div>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>\u524d\u306e\u8a18\u4e8b\u3067\u3001 \u691c\u7d22\u7d50\u679c\u3092\u30ed\u30fc\u30ab\u30eb\u306b\u4fdd\u6301\u3057\u3066\u3042\u308b sqlite \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u7167\u5408\u3059\u308b\u3002\u65b0\u3057\u3044\u3082\u306e\u304c\u3042\u308c\u3070\u305d\u308c\u3092\u30c4\u30a4\u30fc\u30c8\u3059\u308b \u3068\u66f8\u3044\u305f\u3002\u3053\u3053\u306e\u3084\u308a\u65b9\u306f sqlite \u306a\u3089\u3067\u306f\u306e\u3082\u306e\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u4e00\u5fdc\u30e1\u30e2\u3057\u3066\u304a\u304f\u3002 \u666e\u901a\u306b\u8003\u3048\u308b\u3068\u3001\u756a\u7d44 A \u304c\u65e2\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u3042\u308b\u304b\u3092\u7167\u5408\u3057\u3001\u305d\u306e\u7d50\u679c\u306b\u3088\u3063\u3066\u51e6\u7406\u3092\u632f\u308a\u5206\u3051\u308b\u306b\u306f [cci]select * from program where name=:A[\/cci] \u3059\u308b \u30ec\u30b3\u30fc\u30c9\u30bb\u30c3\u30c8\u304c\u884c\u3092\u8fd4\u3055\u306a\u304b\u3063\u305f\u3089 [cci]insert into program (name) values (:A)[\/cci] \u3059\u308b\u3002\u305d\u3057\u3066\u30c4\u30a4\u30fc\u30c8\u3059\u308b \u3068\u30011 \u756a\u7d44\u306b\u3064\u304d 2 \u56de\u30af\u30a8\u30ea\u3092\u767a\u884c\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002\u3053\u308c\u306f\u7121\u99c4\u306a\u611f\u3058\u304c\u3059\u308b\u306e\u3067\u3001\u4f8b\u306e sqlite \u5074\u306e\u95a2\u6570\u306e\u5b9f\u4f53\u3092 php \u3067\u5b9f\u88c5\u3067\u304d\u308b\u6a5f\u80fd\u3092\u4f7f\u3046\u3002 $db = new SQLite3(&#8220;program.db&#8221;); $db->createFunction(&#8220;php_name&#8221;, __NAMESPACE__ . &hellip; <a href=\"https:\/\/appsweets.net\/blog\/2016\/09\/28\/abeanibot-introduced-2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50,30],"class_list":["post-2024","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-abeani","tag-php"],"_links":{"self":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts\/2024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/comments?post=2024"}],"version-history":[{"count":2,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts\/2024\/revisions"}],"predecessor-version":[{"id":2026,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/posts\/2024\/revisions\/2026"}],"wp:attachment":[{"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/media?parent=2024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/categories?post=2024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appsweets.net\/blog\/wp-json\/wp\/v2\/tags?post=2024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}