Add to collection
Expert User

Expert User

Verified

Get Auto increment ID in MYSQL using codeigniter

Get auto-increment id which is next to be generated in the tables.

 Here in this case, "cookietable" is a MySQL table whose auto-increment ID you want. This will give you the next ID which will be generated when the next insert will happen in the table.

$next = $this->db->query("SHOW TABLE STATUS LIKE 'cookietable'");

$next = $next->row(0);

$next->Auto_increment;

echo $next->Auto_increment;

NA
NA
$next = $this->db->query("SHOW TABLE STATUS LIKE 'cookietable'");
$next = $next->row(0);
$next->Auto_increment;
echo $next->Auto_increment;

Comments 0

  • Sorry!! No comment posted yet. Become the first user to give comment.
Add a comment

Would you like to write for w3 sniff?

Become part of an amazing group of contributors and authors and start writing for us

Join Now
NA
NA
$next = $this->db->query("SHOW TABLE STATUS LIKE 'cookietable'");
$next = $next->row(0);
$next->Auto_increment;
echo $next->Auto_increment;
Feedback submitted successfully.