On an inconsistent basis an unaccessible program will insert a record into a mysql database table. Instead of constantly querying the table looking for new inserts, is there a way to have mysql trigger a php script to run when the record is inserted?

Perhaps someone has done this before and could suggest a method.

Thanks,

Andrew Pasetti

    As far as I know, MySQL does not support such a feature. Although PostgreSQL does, in the form of the LISTEN directive. That means that you could add an INSERT trigger that would simply call "NOTIFY your_event" -- in which case the application would be able to handle the insert event.

    However, as you're using an inferior (🙂) database, I'm afraid that this is not possible.

      Actually, it's even less work with PostgreSQL, thanks to plphp, you can now just have a php script get fired off everytime a row gets inserted / updated. You can even write your triggers in PHP now.

        Write a Reply...