I have a table called lists
. This list is filled with multiple rows at a time. The first time the table is filled with 3 rows. And after that, any update of this table may be 2 rows or 6 rows.
I want to delete/update accordingly. Meaning, if the next update has less rows than the current, then the rest of the rows should be deleted. Or if the next row is greater then the current row, then the respective rows should update and the rest are added with auto incremented id's.
I am using CakePHP 2.6.7.
I'm not sure if I understood your question, but maybe you want to use something like
Model::saveAll()
That will execute the following commands:
To delete more than one record use
Model::delete()
:That will execute the following SQL command:
Read more about
Model::updateAll()
andModel::saveAll()
here, and aboutModel::delete()
andModel::deleteAll()
hereI hope it will help you.