Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Live update notification on database changes MYSQL PHP

Tags:

php

mysql

I was wondering how to trigger a notification if a new record is inserted into a database, using PHP and MySQL.

like image 732
mohamadfikri Avatar asked Apr 13 '09 08:04

mohamadfikri


2 Answers

You can create a trigger than runs when an update happens. It's possible to run/notify an external process using a UDF (user defined function). There aren't any builtin methods of doing so, so it's a case of loading a UDF plugin that'll do it for you.

Google for 'mysql udf sys_exec' or 'mysql udf ipc'.

like image 88
steveayre Avatar answered Oct 27 '22 01:10

steveayre


The simplest thing is probably to poll the DB every few seconds and see if new records have been inserted. Due to query caching in the DB this shouldn't effect DB performance substantially.

like image 32
Assaf Lavie Avatar answered Oct 27 '22 02:10

Assaf Lavie