{"id":954,"date":"2021-03-21T21:40:26","date_gmt":"2021-03-21T13:40:26","guid":{"rendered":"http:\/\/www.tra56.com\/?p=954"},"modified":"2021-03-21T21:40:26","modified_gmt":"2021-03-21T13:40:26","slug":"954","status":"publish","type":"post","link":"https:\/\/www.tra56.com\/954.html","title":{"rendered":"PHP\u64cd\u4f5cmysql\u6570\u636e\u5e93\u5206\u8868\u7684\u65b9\u6cd5"},"content":{"rendered":"

\u4e00\u822c\u6765\u8bf4\uff0c\u5f53\u6211\u4eec\u7684\u6570\u636e\u5e93\u7684\u6570\u636e\u8d85\u8fc7\u4e86100w\u8bb0\u5f55\u7684\u65f6\u5019\u5c31\u5e94\u8be5\u8003\u8651\u5206\u8868\u6216\u8005\u5206\u533a\u4e86\uff0c\u8fd9\u6b21\u6211\u6765\u8be6\u7ec6\u8bf4\u8bf4\u5206\u8868\u7684\u4e00\u4e9b\u65b9\u6cd5\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u60f3\u597d\u5230\u5e95\u5206\u591a\u5c11\u4e2a \u8868\uff0c\u524d\u63d0\u5f53\u7136\u662f\u6ee1\u8db3\u5e94\u7528\u3002\u8fd9\u91cc\u6211\u4f7f\u7528\u4e86\u4e00\u4e2a\u6bd4\u8f83\u7b80\u5355\u7684\u5206\u8868\u65b9\u6cd5\uff0c\u5c31\u662f\u6839\u636e\u81ea\u589eid\u7684\u5c3e\u6570\u6765\u5206\uff0c\u4e5f\u5c31\u662f\u8bf4\u52060-9\u4e00\u517110\u4e2a\u8868\uff0c\u5176\u53d6\u503c\u4e5f\u5f88\u597d\u505a\uff0c\u5c31\u662f\u5bf910 \u8fdb\u884c\u53d6\u6a21\u3002\u53e6\u5916\uff0c\u8fd8\u53ef\u4ee5\u6839\u636e\u67d0\u4e00\u5b57\u6bb5\u7684md5\u503c\u53d6\u5176\u4e2d\u51e0\u4f4d\u8fdb\u884c\u5206\u8868\uff0c\u8fd9\u6837\u7684\u8bdd\uff0c\u53ef\u4ee5\u5206\u7684\u8868\u5c31\u5f88\u591a\u4e86\u3002<\/p>\n

\u597d\u4e86\uff0c\u5148\u6765\u521b\u5efa\u8868\u5427\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

CREATE TABLE `ttlsa_com`.`article_0` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_1` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_2` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_3` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_4` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_5` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_6` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_7` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_8` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci\r\nCREATE TABLE `ttlsa_com`.`article_9` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci<\/pre>\n

\u597d\u4e8610\u4e2a\u8868\u521b\u5efa\u5b8c\u6bd5\u4e86\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u7684id\u4e0d\u80fd\u8bbe\u4e3a\u81ea\u589e\uff0c\u800c\u4e14\u6240\u6709\u7684\u8868\u7ed3\u6784\u5fc5\u987b\u4e00\u81f4\uff0c\u5305\u62ec\u7ed3\u6784\uff0c\u7c7b\u578b\uff0c\u957f\u5ea6\uff0c\u5b57\u6bb5\u7684\u987a\u5e8f\u90fd\u5fc5\u987b\u4e00\u81f4\u90a3\u4e48\u5bf9\u4e8e\u8fd9\u4e2aid\u5982\u4f55\u53d6\u5f97\u5462\uff1f\u540e\u9762\u6211\u4f1a\u8be6\u7ec6\u8bf4\u660e\u3002\u73b0\u5728\uff0c\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u5408\u5e76\u8868\uff0c\u7528\u4e8e\u67e5\u8be2\uff0c\u521b\u5efa\u5408\u5e76\u8868\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/span><\/p>\n

CREATE TABLE `ttlsa_com`.`article` ( \r\n`id` BIGINT( 20 ) NOT NULL ,\r\n`subject` VARCHAR( 200 ) NOT NULL ,\r\n`content` TEXT NOT NULL ,\r\nPRIMARY KEY ( `id` )\r\n) ENGINE=MRG_MyISAM DEFAULT CHARSET=utf8 INSERT_METHOD=0 union =(`article_0`,`article_1`,`article_2`,`article_3`,`article_4`,`article_5`,`article_6`,`article_7`,`article_8`,`article_9`);<\/pre>\n

\u6ce8\u610f\uff0c\u5408\u5e76\u8868\u4e5f\u5fc5\u987b\u548c\u524d\u9762\u7684\u8868\u6709\u76f8\u540c\u7684\u7ed3\u6784\uff0c\u7c7b\u578b\uff0c\u957f\u5ea6\uff0c\u5305\u62ec\u5b57\u6bb5\u7684\u987a\u5e8f\u90fd\u5fc5\u987b\u4e00\u81f4\u8fd9\u91cc\u7684INSERT_METHOD=0\u8868\u793a\u4e0d\u5141\u8bb8\u5bf9\u672c\u8868\u8fdb\u884c insert\u64cd\u4f5c\u3002\u597d\u4e86\uff0c\u5f53\u9700\u8981\u67e5\u8be2\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u53ea\u5bf9article\u8fd9\u4e2a\u8868\u8fdb\u884c\u64cd\u4f5c\u5c31\u53ef\u4ee5\u4e86\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e2a\u8868\u4ec5\u4ec5\u53ea\u80fd\u8fdb\u884cselect\u64cd\u4f5c\uff0c\u90a3\u4e48\u5bf9\u4e8e \u63d2\u5165\u4e5f\u5c31\u662finsert\u64cd\u4f5c\u5e94\u8be5\u5982\u4f55\u6765\u641e\u5462\uff0c\u9996\u5148\u5c31\u662f\u83b7\u53d6\u552f\u4e00\u7684id\u4e86\uff0c\u8fd9\u91cc\u5c31\u8fd8\u9700\u8981\u4e00\u4e2a\u8868\u6765\u4e13\u95e8\u521b\u5efaid\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/span><\/p>\n

CREATE TABLE `ttlsa_com`.`create_id` ( \r\n`id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY \r\n) ENGINE = MYISAM<\/pre>\n

\u4e5f\u5c31\u662f\u8bf4\uff0c\u5f53\u6211\u4eec\u9700\u8981\u63d2\u5165\u6570\u636e\u7684\u65f6\u5019\uff0c\u5fc5\u987b\u7531\u8fd9\u4e2a\u8868\u6765\u4ea7\u751fid\u503c\uff0c\u6211\u7684php\u4ee3\u7801\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/span><\/p>\n

<?php \r\nfunction get_AI_ID() { \r\n$sql = "insert into create_id (id) values('')"; \r\n$this->db->query($sql); \r\nreturn $this->db->insertID(); \r\n} \r\n?><\/pre>\n

\u597d\u4e86\uff0c\u73b0\u5728\u5047\u8bbe\u6211\u4eec\u8981\u63d2\u5165\u4e00\u6761\u6570\u636e\u4e86\uff0c\u5e94\u8be5\u600e\u4e48\u64cd\u4f5c\u5462\uff1f\u8fd8\u662f\u7ee7\u7eed\u770b\u4ee3\u7801\u5427<\/span><\/p>\n

<?php \r\nfunction new_Article() { \r\n$id = $this->get_AI_ID(); \r\n$table_name = $this->get_Table_Name($id); \r\n$sql = "insert into {$table_name} (id,subject,content) values('{$id}','\u6d4b\u8bd5\u6807\u9898','\u6d4b\u8bd5\u5185\u5bb9')"; \r\n$this->db->query($sql); \r\n} \r\n\/** \r\n* \u7528\u4e8e\u6839\u636eid\u83b7\u53d6\u8868\u540d \r\n*\/ \r\nfunction get_Table_Name($id) { \r\nreturn 'article_'.intval($id)%10; \r\n} \r\n?><\/pre>\n

\u5176\u5b9e\u5f88\u7b80\u5355\u7684\uff0c\u5bf9\u5427\uff0c\u5c31\u662f\u5148\u83b7\u53d6id\uff0c\u7136\u540e\u6839\u636eid\u83b7\u53d6\u5e94\u8be5\u63d2\u5165\u5230\u54ea\u4e2a\u8868\uff0c\u7136\u540e\u5c31\u5f88\u7b80\u5355\u4e86\u3002
\u5bf9\u4e8eupdate\u7684\u64cd\u4f5c\u6211\u60f3\u5e94\u8be5\u4e0d\u9700\u8981\u518d\u8bf4\u4e86\u5427\uff0c\u65e0\u975e\u662f\u6709\u4e86id\uff0c\u7136\u540e\u83b7\u53d6\u8868\u540d\uff0c\u7136\u540e\u8fdb\u884cupdate\u64cd\u4f5c\u5c31\u597d\u4e86\u3002
\u5bf9\u4e8e\u7528\u6237\u8868\uff0c\u5efa\u4e2a\u6700\u5c11\u5217\u6700\u57fa\u672c\u4fe1\u606f\u7684\u7528\u6237\u540d\uff0c\u6bd4\u5982\u7528\u6237ID\uff0c\u7528\u6237\u540d\uff0c\u5bc6\u7801\u3002\u7528\u6237\u7684\u5176\u4ed6\u4fe1\u606f\u5206\u5e03\u5230\u4ee5\u7528\u6237ID\u5206\u8868\u7684\u8868\u4e0a\u3002
\u600e\u4e48\u5206\u8868\u5982\u4f55\u5206\u8868\u4ee5\u4e1a\u52a1\u9700\u6c42\u800c\u5b9a\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u6839\u636eid\u5206\uff0c\u4e5f\u53ef\u4ee5\u6839\u636e\u5e74\uff0c\u6708\uff0c\u5730\u533a\u6765\u5206\u3002\u8981\u6309\u7167\u4e1a\u52a1\u9700\u6c42\u3002<\/p>\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4e00\u822c\u6765\u8bf4\uff0c\u5f53\u6211\u4eec\u7684\u6570\u636e\u5e93\u7684\u6570\u636e\u8d85\u8fc7\u4e86100w\u8bb0\u5f55\u7684\u65f6\u5019\u5c31\u5e94\u8be5\u8003\u8651\u5206\u8868\u6216\u8005\u5206\u533a\u4e86\uff0c\u8fd9\u6b21\u6211\u6765\u8be6\u7ec6\u8bf4\u8bf4\u5206\u8868\u7684\u4e00\u4e9b\u65b9\u6cd5 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[26,72,70],"class_list":["post-954","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/954"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=954"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/954\/revisions"}],"predecessor-version":[{"id":955,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/954\/revisions\/955"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}