primary key - MySQL ID Increment Conundrum -


i have mysql table auto increment. i'm using id primary key.

here structure of key:: id int(255) no none auto_increment

this how increments have happened:

for reason wasn't accepting question data. admins please note

as can see xxxxxxxxyy series, yy numbers incremented.


this insert statement.

$id = $this->get_next_id($this->get_last_id()); $q = 'insert '.url_table.' (id, url, date, title, image, description)  values ("'.$id.'", "'.$url.'", now(), "'.$title.'", "'.$image.'", "'.$description.'")'; 

there no need give new id. column auto_increment, increment automatically (hence name).

just insert this, , let database handle increments:

$q = 'insert '.url_table.' (url, date, title, image, description)  values ("'.$url.'", now(), "'.$title.'", "'.$image.'", "'.$description.'")'; 

(just omit id column altogether)


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -