Get Auto increment ID in MYSQL using codeigniter

Expert User Verified
Get auto-increment id which is next to be generated in the tables.
NA
NA
$next = $this->db->query("SHOW TABLE STATUS LIKE 'cookietable'");
$next = $next->row(0);
$next->Auto_increment;
echo $next->Auto_increment;

 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;

Comments

Leave a Comment