I have a mysql table with auto increment. I'm using an id as the primary key.
Here is the structure of the key:: id int(255) No None AUTO_INCREMENT
This is how the increments have happened:
As you can see xxxxxxxxYY series, only the YY numbers are incremented.
This is the insert statement.
$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.'")';
There is no need to give a new ID. Your column is AUTO_INCREMENT
, so it will increment automatically (hence the name).
Just insert like this, and let the database handle the increments:
$q = 'INSERT INTO '.URL_TABLE.' (url, date, title, image, description)
VALUES ("'.$url.'", NOW(), "'.$title.'", "'.$image.'", "'.$description.'")';
(Just omit the id
column altogether)