2

I've this forum sort of website which is already in place, now the client wants to implement notification system onto it. What's the optimum way out.

My table typically looks like this at the moment:

Id | to | from | Message | is_read | Time | Link

Now the real question is ... is there any alternate way to push data onto this table than going to each relevant controller and fire a subsequent insert once the main insert is successful. I was thinking of using hooks but I couldn't find how to hook a function after a model function is successful or a controller function.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

1

Instead of updating each controller that deals with that table you should update the model once.

Whenever you call your method in your model for updating that particular table you can have it call another method after or before it inserts/updates your records that performs the task you need.

A good CodeIgniter base model I like to use for this kind of stuff is MY_Model by jamierumbelow. (https://github.com/jamierumbelow/codeigniter-base-model)

It allows you to hook into before_create/after_create/before_update/etc and it works well with CodeIgniters validation.

Overachiever
  • 865
  • 7
  • 10