Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to check if new data is added in my database using fuelphp?
  • How to check if new data is added in my database using fuelphp? I have a database that accept new users. I want to be notified if new user is added on the database. I already have email notification of the new registered but I want a notification inside the system, like for example I have if my db count now is 1000, and after 1 hour it's 1001 already so notification will show in my admin account "new user has registered.". My idea is to add a new table in my db that will count and save the old number of users and then check if the old value is the same of new count. But I don't want to add a table just for saving the number of users. Is it possible? Thanks
  • User table has created_at and last_login fields. Select all users with created_at time greater then last_login of admin user.
  • Add an observer that is triggered on insert, and have that do something? It's the closest you can get, and always accurate.
  • Thanks bvn and Harro.

    Harro, are you talking about the obserser for the created_at and last_login that was suggested by bvn?
  • An observer executes a specific task, at a specific event.

    Fuel comes with a few standard observers, like created_at and updated_at. The last_login column is specific to Auth, and is not used for this purpose, it's used to detect and block concurrent logins (unless you have enabled that). It is not updated using an observer.

    But you can write your own observers, either as a separate class, or as a method in the model with the help of Observer_Self, see http://docs.fuelphp.com/packages/orm/observers/creating.html. If you trigger your observer on "after_insert", it will only be executed on a succesful insert.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion