E
E
Eugene2018-02-27 10:17:54
Yii
Eugene, 2018-02-27 10:17:54

How to make automatic deletion of old records?

There are two questions. I have coupons in the database. They have a date and time. How to automatically delete coupons that are older than the current date? To keep the base clean.
And another question. Is it possible to set up auto-increment in the database? Let's say there were 15 coupons and they were numbered from 1 to 15. I deleted the last 4 pcs. But when creating a new coupon, he was assigned the number 16. And not the number 12.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-02-27
@evgen9586

Good morning.
1) By cron run a console script that will clear the database from old entries.
2) No.
The correct solution would not be to edit autoincrement, but to create a separate field in the table for serial numbering of coupons. Or even easier, use in the gridview, for example, SerialColumn

D
Dmitry Kim, 2018-02-27
@kimono

1) cron
2) ALTER TABLE tbl AUTO_INCREMENT = 12;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question