0

我有一个自动递增的 mysql 表。我使用 id 作为主键。

这是键的结构:: id int(255) 否 无 AUTO_INCREMENT

增量是这样发生的:

出于某种原因,SO 不接受这个数据的问题。 请管理员注意

如您所见,xxxxxxxxYY 系列,只有 YY 数字递增。


这是插入语句。

$id = $this->get_next_id($this->get_last_id());
$q = 'INSERT INTO '.URL_TABLE.' (id, url, date, title, image, description) 
VALUES ("'.$id.'", "'.$url.'", NOW(), "'.$title.'", "'.$image.'", "'.$description.'")';
4

1 回答 1

2

无需提供新 ID。您的列是AUTO_INCREMENT,因此它将自动增加(因此得名)。

像这样插入,让数据库处理增量:

$q = 'INSERT INTO '.URL_TABLE.' (url, date, title, image, description) 
VALUES ("'.$url.'", NOW(), "'.$title.'", "'.$image.'", "'.$description.'")';

(完全省略该id列)

于 2013-04-18T19:47:57.970 回答