Ticket #888 (closed Patch: invalid)
ORM delete_all() does not alter the primary_key back to 1
| Reported by: | shahid | Owned by: | Shadowhand |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.2.1 |
| Component: | Libraries:ORM | Version: | 2.2 Release |
| Keywords: | ORM delete_all truncate auto_increment | Cc: |
Description
For any table with auto_increment field i.e. the primary key, delete_all() does not alter the primary key back to 1. For instance if you have 50 records in books table, the following code will delete all records BUT the next record will start from 51 NOT 1 again.
// delete all records $book = ORM::factory("book")->delete_all();
// create a new record $book = ORM::factory("book"); $book->title = 'My new book'; $book->save();
// output the id of this new row echo $book->id; // will output 51
Was this intentional? If so, how can we then truncate an entire table which will them empty out all rows and the auto_increment will start from 1??
Hope it makes sense.
Thanks.
