{"id":391,"date":"2023-02-23T18:04:05","date_gmt":"2023-02-23T09:04:05","guid":{"rendered":"https:\/\/intinfinity.com\/?p=391"},"modified":"2023-02-23T18:04:09","modified_gmt":"2023-02-23T09:04:09","slug":"sqlite%e3%81%ab%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%82%92%e5%85%a5%e3%82%8c%e3%81%a6%e5%85%a5%e5%8a%9b%e3%81%ab%e3%83%9e%e3%83%83%e3%83%81%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/intinfinity.com\/index.php\/archives\/391","title":{"rendered":"SQLite\u306b\u6b63\u898f\u8868\u73fe\u30d1\u30bf\u30fc\u30f3\u3092\u5165\u308c\u3066\u5165\u529b\u306b\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u308a\u51fa\u3059"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u80cc\u666f<\/h2>\n\n\n\n<p>\u5148\u982d\u306b\u30b0\u30eb\u30fc\u30d7\u306e\u610f\u5473\u3092\u542b\u3093\u3067\u3044\u308bID\u304c\u3042\u308a\u3001\u305d\u306eID\u3092\u4f7f\u3063\u3066\u305d\u306eID\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306e\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3059\u3068\u3044\u3046\u5b9f\u88c5\u304c\u3057\u305f\u304f\u306a\u3063\u305f\u3002\u8f9e\u66f8\u7684\u306b\u4f7f\u3044\u305f\u3044\u3002<\/p>\n\n\n\n<p>\u5168\u90e8\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u5f15\u3063\u5f35\u308a\u51fa\u3057\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5074(PHP)\u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u3066\u63a2\u3057\u3066\u3082\u3044\u3044\u306e\u3060\u304c\u3001DB\u306a\u3089\u3082\u3063\u3068\u30b9\u30de\u30fc\u30c8\u306a\u5b9f\u88c5\u65b9\u6cd5\u304c\u3042\u308b\u306e\u3067\u306f\u306a\u304b\u308d\u3046\u304b\u3068\u3002<\/p>\n\n\n\n<p>SQL\u6587\u3067\u5b9f\u73fe\u3067\u304d\u305f\u306e\u3067\u3001\u305d\u306e\u3084\u308a\u65b9\u3092\u8a18\u4e8b\u306b\u3059\u308b\u3002<\/p>\n\n\n\n<p>DB\u306b\u3059\u3079\u3066\u306eID\u3092\u767b\u9332\u3057\u3066\u3001\u30b0\u30eb\u30fc\u30d7\u540d\u3092\u3064\u3051\u3066\u304a\u3051\u3070\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u4eca\u56de\u306e\u8981\u4ef6\u3067\u306f\u3053\u308c\u3092\u4f7f\u3048\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u30ec\u30b3\u30fc\u30c9\u306b\u30d1\u30bf\u30fc\u30f3\u304c\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u4f8b\u3067\u3059\u304c\u3001\u9006\u306bSQL\u6587\u3067\u30d1\u30bf\u30fc\u30f3\u3092\u6307\u5b9a\u3059\u308b\u30b1\u30fc\u30b9\u306e\u3046\u3061\u3001\u30d1\u30bf\u30fc\u30f3\u304c\u7c21\u5358\u306a\u5834\u5408\u306f LIKE\u53e5 \u3084 GLOB\u53e5 \u304c\u4f7f\u7528\u3067\u304d\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u3061\u3089\u306e\u307b\u3046\u304c\u74b0\u5883\u3084\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u4f9d\u5b58\u3057\u305a\u3089\u3044\u306e\u3067\u304a\u3059\u3059\u3081\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9a\u7fa9\u306e\u5b9f\u88c5<\/h2>\n\n\n\n<p>SQLite\u306bpreg_match()\u3092UDF(\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u95a2\u6570)\u3068\u3057\u3066\u767b\u9332\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092DB\u3092\u958b\u3044\u305f\u5f8c\u3042\u305f\u308a\u306b\u8a18\u8ff0\u3059\u308b\u3002DB\u3092\u958b\u3044\u305f\u6642\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306f\u5404\u81ea\u9055\u3046\u3068\u601d\u3046\u306e\u3067\u3001\u9069\u5b9c\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>SQLite3 \u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ($db->createFunction(\"preg_match\", \"preg_match\", 2) === FALSE) {\n    exit(\"Failed creating function\\n\");\n}<\/code><\/pre>\n\n\n\n<p>PDO \u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ($db->sqliteCreateFunction('preg_match', 'preg_match', 2) === FALSE) {\n    exit(\"Failed creating function\\n\");\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">SQL\u306e\u5b9f\u884c\u5b9f\u88c5<\/h2>\n\n\n\n<p>SQL\u6587\u3067preg_match()\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3001SQL\u6587\u306b\u7d44\u307f\u8fbc\u3080\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306fID\u3092\u5165\u529b\u3057\u3066\u3001\u305d\u308c\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u308a\u51fa\u3057\u305f\u3044\u306e\u3067\u3001SELECT\u6587\u3068\u3059\u308b\u3002FROM\u53e5\u306f\u901a\u5e38\u901a\u308a\u30c6\u30fc\u30d6\u30eb\u540d\u306e\u6307\u5b9a\u3002\u30dd\u30a4\u30f3\u30c8\u306fWHERE\u53e5\u306b\u6307\u5b9a\u3059\u308bpreg_match()\u306e\u547c\u3073\u51fa\u3057\u3002<\/p>\n\n\n\n<p>\u4e0b\u8a18\u306e\u4f8b\u3067\u306f\u3001table1\u30c6\u30fc\u30d6\u30eb\u306e\u5185\u3001id_pattern\u30ab\u30e9\u30e0(TEXT\u578b)\u306b\u6b63\u898f\u8868\u73fe\u30d1\u30bf\u30fc\u30f3\u304c\u5165\u3063\u3066\u3044\u3066\u3001ID\"hogehoge\"\u304c\u30de\u30c3\u30c1\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u306e\u5168\u30ab\u30e9\u30e0\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u308bSQL\u6587\u306e\u4f8b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM table1 WHERE preg_match(id_pattern, \"hogehoge\");<\/code><\/pre>\n\n\n\n<p>\u3053\u306eSQL\u6587\u306b\u9650\u3089\u305a\u3001\u7279\u306b\u5916\u90e8\u304b\u3089\u306e\u5165\u529b\u3092\u4f7f\u3046\u5834\u5408\u3001\u5b89\u5168\u306e\u305f\u3081\u306b\u30d7\u30ea\u30da\u30a2\u30c9\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u8cc7\u6599<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.php.net\/manual\/ja\/sqlite3.createfunction.php\" target=\"_blank\" rel=\"noreferrer noopener\">PHP: SQLite3::createFunction - Manual<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.php.net\/manual\/ja\/pdo.sqlitecreatefunction.php\" target=\"_blank\" rel=\"noreferrer noopener\">PHP: PDO::sqliteCreateFunction - Manual<\/a><\/p>\n\n\n\n<p><a href=\"http:\/\/www.karak.jp\/blog\/sqlite-regexp.html\" target=\"_blank\" rel=\"noreferrer noopener\">SQLite\u3067\u6b63\u898f\u8868\u73fe | karak<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u5148\u982d\u306b\u30b0\u30eb\u30fc\u30d7\u306e\u610f\u5473\u3092\u542b\u3093\u3067\u3044\u308bID\u304c\u3042\u308a\u3001\u305d\u306eID\u3092\u4f7f\u3063\u3066\u305d\u306eID\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306e\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3059\u3068\u3044\u3046\u5b9f\u88c5\u304c\u3057\u305f\u304f\u306a\u3063\u305f\u3002\u8f9e\u66f8\u7684\u306b\u4f7f\u3044\u305f\u3044\u3002 \u5168\u90e8\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u5f15\u3063\u5f35\u308a\u51fa\u3057\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5074(PHP)\u3067\u6b63\u898f\u8868 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,17,19],"tags":[],"class_list":["post-391","post","type-post","status-publish","format-standard","hentry","category-php","category-programming","category-sql"],"_links":{"self":[{"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":8,"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"predecessor-version":[{"id":399,"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/posts\/391\/revisions\/399"}],"wp:attachment":[{"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/intinfinity.com\/index.php\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}