{"id":161,"date":"2017-04-14T14:11:01","date_gmt":"2017-04-14T06:11:01","guid":{"rendered":"https:\/\/himmel.tech\/wp\/?p=161"},"modified":"2017-04-27T15:34:11","modified_gmt":"2017-04-27T07:34:11","slug":"%e5%bc%80%e5%8f%91%e6%97%a5%e5%bf%97-170414","status":"publish","type":"post","link":"https:\/\/himmel.tech\/wp\/?p=161","title":{"rendered":"\u5f00\u53d1\u65e5\u5fd7 170414"},"content":{"rendered":"<p>\u524d\u5929\u548c\u6628\u5929\u6298\u817e\u4e86\u597d\u4e45\u963f\u91cc\u4e91\u7684\u670d\u52a1\u5668\uff0c\u5404\u79cd\u7528\u7684\u4e0d\u723d\uff0c\u6700\u540e\u8fd8\u662f\u5f3a\u884c\u7ed9\u88c5\u4e86\u5927\u8725\u873442.2\u3002\u4eca\u5929\u4e3b\u8981\u6298\u817e\u4e86\u4e00\u4e0b\u6570\u636e\u5e93\u7684\u521d\u59cb\u5316\uff0c\u4ee5\u53ca\u5c1d\u8bd5\u901a\u8fc7MySQL Connector\/C++\u8fde\u63a5\u5230\u6570\u636e\u5e93\u4e0a\u3002<\/p>\n<p>\u7b80\u5355\u53c2\u8003\u4e86\u8fd9\u7bc7\u6559\u7a0b\uff1a<a href=\"http:\/\/blog.csdn.net\/tiaotiaoyly\/article\/details\/5174772\">http:\/\/blog.csdn.net\/tiaotiaoyly\/article\/details\/5174772<\/a><\/p>\n<p><!--more--><\/p>\n<p>\u9996\u5148\u5b89\u88c5\u597dnginx, php5-fpm, php5-mbstring, php5-mysql, mariadb\u8fd9\u51e0\u4e2a\u5305\uff0c\u7136\u540e\u5199\u597dnginx\u914d\u7f6e\u6587\u4ef6\uff0c\u628aphpMyAdmin\u5f00\u8d77\u6765\u3002\u7136\u540e\u88c5mariadb\uff0c\u542f\u52a8\u4e4b\u540e\u8fd0\u884cmysql_secure_installation\u811a\u672c\uff0c\u5c31\u53ef\u4ee5\u5728phpMyAdmin\u91cc\u8bbf\u95ee\u4e86\u3002\u5f53\u7136\uff0c\u63a8\u8350\u628aHTTPS\u4e5f\u5f00\u8d77\u6765\uff0c\u963f\u91cc\u4e91\u548c\u817e\u8baf\u4e91\u6709\u514d\u8d39\u8bc1\u4e66\u53ef\u4ee5\u7533\u8bf7\uff0c\u4e5f\u4e0d\u8d39\u4e8b\u3002<\/p>\n<p>\u7136\u540e\u5f00\u59cb\u5728\u672c\u673a\u641e\u4e8b\u60c5\uff0c\u5b89\u88c5libmysqlcppconn-devel\u8fd9\u4e2a\u5305\uff0c\u91cc\u9762\u5305\u542b\u4e86\u8fde\u63a5MySQL\u6240\u9700\u8981\u7684\u5e93\u548c\u5934\u6587\u4ef6\uff0cboost\u7684\u4f9d\u8d56\u4f3c\u4e4e\u6ca1\u5199\u8fdb\u53bb\uff0c\u8fd8\u8981\u624b\u52a8\u5b89\u88c5\u4e00\u4e0bboost_1_63-devel\u8fd9\u4e2a\u5305\u3002<\/p>\n<p>\u6211\u7684\u6570\u636e\u5e93\u957f\u8fd9\u4e2a\u6837\u5b50\uff0c<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">MariaDB [test]&gt; select * FROM Books;\n+--------------------+-------+---------+-------+\n| Name               | Price | ISBN    | Count |\n+--------------------+-------+---------+-------+\n| \u81ea\u52a8\u65e5\u5c71\u539f\u7406       |  99.8 | 1213141 |   999 |\n| \u81ea\u52a8CI\u539f\u7406         |  97.2 |   12333 |     1 |\n+--------------------+-------+---------+-------+\n2 rows in set (0.04 sec)\n<\/pre>\n<p>\u7136\u540e\u5199\u4e00\u6bb5\u5c0f\u7a0b\u5e8f\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include &lt;mysql_connection.h&gt;\n#include &lt;mysql_driver.h&gt;\n#include &lt;cppconn\/statement.h&gt;\nusing namespace sql;\nusing namespace std;\n\nvoid RunConnectMySQL()\n{\n  mysql::MySQL_Driver *driver;\n  Connection *con;\n  Statement *state;\n  ResultSet *result;\n  \/\/ \u521d\u59cb\u5316\u9a71\u52a8\n  driver = sql::mysql::get_mysql_driver_instance();\n  \/\/ \u5efa\u7acb\u94fe\u63a5\n  con = driver-&gt;connect(\"tcp:\/\/ali.himmel.tech\", \"test\", \"nozomiDaisuki\");\n  state = con-&gt;createStatement();\n  state-&gt;execute(\"use test\");\n  state -&gt; execute(\"INSERT INTO Books (Name, ISBN, Price, Count) VALUES ('\u81ea\u52a8\u6253Call\u539f\u7406' , 80211, 199.8, 2999)\");\n  \/\/ \u67e5\u8be2\n  result = state-&gt;executeQuery(\"select * from Books\");\n  \/\/ \u8f93\u51fa\u67e5\u8be2\n  while(result-&gt;next())\n  {\n    cout &lt;&lt; result -&gt; getString(\"Name\") &lt;&lt; \" : $\" &lt;&lt; result -&gt; getDouble(\"Price\")  &lt;&lt; endl;\n  }\n  state -&gt; execute(\"DELETE FROM Books WHERE Name = '\u81ea\u52a8\u6253Call\u539f\u7406'\");\n  delete state;\n  delete con;\n}\n\nint main()\n{\n  RunConnectMySQL();\n  return 0;\n}<\/pre>\n<p>\u6ce8\u610f\u6267\u884c\u547d\u4ee4\u6709\u4e09\u79cd\uff0c\u4e00\u79cd\u662f\u53ea\u8fd4\u56de\u6210\u529f\u4e0e\u5426\u7684execute\uff0c\u4e00\u79cd\u662f\u8fd4\u56de\u6539\u53d8\u884c\u6570\u7684executeUpdate\uff0c\u4ee5\u53ca\u8fd4\u56de\u4e00\u4e2a\u67e5\u8be2\u5217\u8868\u7684executeQuerry\u3002<\/p>\n<p>\u6240\u4ee5\u8bf4\uff0c\u57fa\u672c\u4e0a\u8fd8\u662f\u7528SQL\u8bed\u53e5\uff0cSQL\u4e0d\u597d\u597d\u5b66\u5b66\u53ef\u4e0d\u884c\u2026\u2026<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">\/home\/test\/GP\/sqltest\/cmake-build-debug\/sqltest\n\u81ea\u52a8\u65e5\u5c71\u539f\u7406 : $99.8\n\u81ea\u52a8CI\u539f\u7406 : $97.2\n\u81ea\u52a8\u6253Call\u539f\u7406 : $199.8\n\nProcess finished with exit code 0<\/pre>\n<p>\u7136\u540e\u8fd9\u662f\u8fd4\u56de\u503c\uff0c\u4e0b\u4e00\u6b65\u8981\u8bbe\u8ba1\u4e00\u4e0b\u6570\u636e\u5e93\u55bd\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u5929\u548c\u6628\u5929\u6298\u817e\u4e86\u597d\u4e45\u963f\u91cc\u4e91\u7684\u670d\u52a1\u5668\uff0c\u5404\u79cd\u7528\u7684\u4e0d\u723d\uff0c\u6700\u540e\u8fd8\u662f\u5f3a\u884c\u7ed9\u88c5\u4e86\u5927\u8725\u873442.2\u3002\u4eca\u5929\u4e3b\u8981\u6298\u817e\u4e86\u4e00\u4e0b\u6570\u636e\u5e93\u7684 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/himmel.tech\/wp\/?p=161\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u5f00\u53d1\u65e5\u5fd7 170414\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-development-diary"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p83CFH-2B","_links":{"self":[{"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=161"}],"version-history":[{"count":5,"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions\/166"}],"wp:attachment":[{"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himmel.tech\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}