{"action":"opened","issue":{"url":"https://api.github.com/repos/yiisoft/yii/issues/3915","labels_url":"https://api.github.com/repos/yiisoft/yii/issues/3915/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii/issues/3915/comments","events_url":"https://api.github.com/repos/yiisoft/yii/issues/3915/events","html_url":"https://github.com/yiisoft/yii/issues/3915","id":98164251,"number":3915,"title":"MySql Double Insert (null value for primary-key)","user":{"login":"wsfuyibing","id":5723153,"avatar_url":"https://avatars.githubusercontent.com/u/5723153?v=3","gravatar_id":"","url":"https://api.github.com/users/wsfuyibing","html_url":"https://github.com/wsfuyibing","followers_url":"https://api.github.com/users/wsfuyibing/followers","following_url":"https://api.github.com/users/wsfuyibing/following{/other_user}","gists_url":"https://api.github.com/users/wsfuyibing/gists{/gist_id}","starred_url":"https://api.github.com/users/wsfuyibing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wsfuyibing/subscriptions","organizations_url":"https://api.github.com/users/wsfuyibing/orgs","repos_url":"https://api.github.com/users/wsfuyibing/repos","events_url":"https://api.github.com/users/wsfuyibing/events{/privacy}","received_events_url":"https://api.github.com/users/wsfuyibing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-30T13:04:36Z","updated_at":"2015-07-30T13:04:36Z","closed_at":null,"body":"Debug-ENV\r\na): Yii Framework/2.0.6-dev\r\nb): nginx/1.4.7\r\nc): PHP/5.4.21\r\nd): MySQL/5.5.28\r\n\r\n#1: MySQL-Table Struct\r\n\r\nCREATE TABLE IF NOT EXISTS `tbl_user_ai` (\r\n  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\r\n  PRIMARY KEY (`id`)\r\n) ENGINE=MyISAM DEFAULT CHARSET=utf8;\r\n\r\n\r\n#2: SQL\r\nINSERT INTO `tbl_user_ai` (`id`) VALUES (null);\r\n\r\n#3: Result\r\nTwo Records found\r\n\r\n\r\n#4: PHP-Code(Yii Framework/2.0.6-dev)\r\nreturn $this->getConnection('AI')\r\n->createCommand()\r\n->insert($this->getTable('tbl_user_ai'), ['id' => null])\r\n->execute();\r\n\r\n应用场景\r\nAI表用于全站的id流水号；以id号决定分表时, 存储到哪张表中。\r\n"}}