A
A
AlexAll2021-05-16 21:25:19
PHP
AlexAll, 2021-05-16 21:25:19

How to ignore yii2 TimestampBehavior behavior under certain conditions?

I have a cron that changes the status of posts at a certain time, but since the TimestampBehavior behavior is in the post model, it changes update_at, how best to do so that when the update_at cron works, the date does not change?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexAll, 2021-05-16
@AlexAll

In general, thanks to everyone, I went the other way, I just did updateAll without using the model and that's it

NEWS::updateAll(
                ['status' => NEWS::STATUS_CLOSED_BY_CRON],
                [
                    'and',
                    ['<>', 'status', [NEWS::STATUS_CLOSED_BY_MODERATOR, NEWS::STATUS_CLOSED_BY_USER]],
                    ['<', 'updateDate', $date->getTimestamp()]
                ]
            );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question