{"id":932,"date":"2022-01-03T08:52:28","date_gmt":"2022-01-02T23:52:28","guid":{"rendered":"https:\/\/blog.wsd.sh\/?p=932"},"modified":"2022-01-03T09:06:26","modified_gmt":"2022-01-03T00:06:26","slug":"golang-mariadb-int%e5%9e%8b%e3%81%aecolumn%e3%81%8b%e3%82%89%e5%8f%96%e3%82%8a%e5%87%ba%e3%81%97%e3%81%9fnull%e3%82%92%e5%90%ab%e3%82%80%e6%95%b0%e5%80%a4%e3%82%92%e6%96%87%e5%ad%97%e3%81%ab%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/blog.wsd.sh\/?p=932","title":{"rendered":"<small>Golang MariaDB INT\u578b\u306ecolumn\u304b\u3089\u53d6\u308a\u51fa\u3057\u305fNULL\u3092\u542b\u3080\u6570\u5024\u3092\u6587\u5b57\u578b(string)\u306b\u5909\u63db<\/small>"},"content":{"rendered":"<p>\uff11\uff0emariadb column\u3067\u306eNULL\u3092\u542b\u3080INTE\u578b\u306e\u6570\u5024\u30c7\u30fc\u30bf<br \/>\n\u30fb\u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u578b\uff1aINT<br \/>\n\u30fbNULL\u3092\u8a31\u53ef<br \/>\n\u30fb\u30c7\u30d5\u30a9\u30eb\u30c8\uff1aNULL<br \/>\n\u30fb\u5024\u306e\u4f8b\uff1a2<\/p>\n<p>\uff12\uff0estruct\u3067\u306e\u5b9a\u7fa9<\/p>\n<pre>\r\ntype Person_s struct {\r\nId   *interface{} `json:\"id\"`\r\n}\r\n\u30fb\u30fb\u30fb\r\nvar _r Person_s;\r\n<\/pre>\n<p>\uff13\uff0e\u5024\u304cnil\u306e\u5224\u5b9a<\/p>\n<pre>\r\n if _r.Id != nil {\r\n<\/pre>\n<p>\u5024\u304cnil\u306e\u5834\u5408<br \/>\nmashal\u3059\u308b\u3068null\u306b\u5909\u63db\u3055\u308c\u308b<\/p>\n<p>\uff14\uff0e\u6587\u5b57\u5909\u63db<br \/>\n\u6587\u5b57\u306e&#8221;2&#8243;\u306b\u5909\u63db\u3001\u5909\u63db\u3057\u306a\u3044\u3068\u6570\u5024\u306e 2 \u306b\u306a\u308b<\/p>\n<pre>\r\n  *_r.Id = interface{}( fmt.Sprintf(\"%d\",*_r.Id)) ;\r\n<\/pre>\n<p>\uff15\uff0e\u5168\u4f53<br \/>\nmashal\u306f\u8a18\u8f09\u3057\u3066\u3044\u306a\u3044<\/p>\n<pre>\r\ntype Person_s struct {\r\nId   *interface{} `json:\"id\"`\r\n}\r\n\u30fb\u30fb\u30fb\r\nvar _r Person_s;\r\n\r\nSQL = `SELECT Id FROM bills WHERE email_address = ? `\r\ns := bytes.NewBufferString(\"\");\r\ns.WriteString(SQL);\r\n\r\ndsn := getDataSourceName ();\r\ndb, err := sql.Open(\"mysql\", dsn);\r\nrows, err := db.Query(s.String(), email_address);\r\n\r\nfor rows.Next() {\r\n   err = rows.Scan(&_r.Id)\r\n   if _r.Id != nil {\r\n     *_r.Id = interface{}( fmt.Sprintf(\"%d\",*_r.Id)) ;\r\n   }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uff11\uff0emariadb column\u3067\u306eNULL\u3092\u542b\u3080INTE\u578b\u306e\u6570\u5024\u30c7\u30fc\u30bf \u30fb\u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u578b\uff1aINT \u30fbNULL\u3092\u8a31\u53ef \u30fb\u30c7\u30d5\u30a9\u30eb\u30c8\uff1aNULL \u30fb\u5024\u306e\u4f8b\uff1a2 \uff12\uff0estruct\u3067\u306e\u5b9a\u7fa9 type Person_s str&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/932"}],"collection":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=932"}],"version-history":[{"count":13,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/932\/revisions"}],"predecessor-version":[{"id":942,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/932\/revisions\/942"}],"wp:attachment":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}