S
S
Silverviql2018-05-08 14:16:03
PHP
Silverviql, 2018-05-08 14:16:03

How to properly call a reminder in yii2?

There is a button, when pressed, a window pops up where you can enter text and a date. (For example: Call back 18.00 05/09/2018)
This data is stored in the database.
I need a function to be called when the specified date is less than the current date, something like this:

if ($model->srok < date('Y-m-d H:i:s')  ) {
 $notification->getByIdNotification(12, $id);
   $notification->getSaveNotification();
}

I don't know how to call validation by date. If you push it into a view, then every time it will make a request to the database and load the page.
Approximately the following logic: clicked on the button entered the text-> saving to the database-> checking the condition if the term is < the current date -> calling a function that will display a notification that dude you need to call back on the garbage that you assigned. The question is exactly how to check the condition without loading the page with requests to the database?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-05-08
@Silverviql

without loading the page with queries to the database

how to get data from db without accessing db? That won't work. Here only it is necessary to optimize this process. Sometimes CRON helps in this, so that each user request does not really perform complex logic. Other than that, caching, count requests instead of select, etc.
In the case of notifications, you can look towards sockets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question