MySQL插入数据后返回自增ID的方法:
SELECT LAST_INSERT_ID();
经典实例:
INSERT INTO `ge_news` (`catid`, `typeid`, `title`, `style`, `thumb`, `keywords`, `description`, `posids`, `url`, `listorder`, `status`, `sysadd`, `islink`, `username`, `inputtime`, `updatetime`, `contype`) VALUES ( 25, 0, ‘标题’, ”, ”, ”, ”, 0, ‘http://localhost/1gear/index.php?m=content&c=index&a=show&catid=25&id=1’, 0, 99, 1, 0, ‘admin’, ’‘,’‘,’news’);
INSERT INTO `ge_news_data` (`id`, `content`, `readpoint`, `groupids_view`, `paginationtype`, `maxcharperpage`, `template`, `paytype`, `relation`, `voteid`, `allow_comment`, `copyfrom`) VALUES ((SELECT LAST_INSERT_ID()),’内容’, 0, ”, 0, 10000, ”, 0, ”, 0, 1, ‘|0’);