I want to truncate my Database Table, with CakePHP Model, I have used $this->Model->deleteAll
code for the same, and it works fine.
Now, What i want is, next time whenever my new records are inserting, it should start ID
with 1 only, which does not work with deleteAll
function, so Is there any default CakePHP Syntax to make table Truncate ?
Let me know !
NOTE: This answer is valid only up to CakePHP 1.3. I haven't used this on the never versions so I've no idea whether it works.
deleteAll
only deletes the data, it does not truncate the table.
You'll need to call the query()
method.
$this->Model->query('TRUNCATE TABLE table_name_in_mysql;')
http://book.cakephp.org/view/1027/query
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With