Very simple question, looking on google brings up plenty of MySQL resources on triggers but I can't find the answer I am looking for.

What I want to know is; When I perform a query on a database from PHP, Does MySQL provide any way for PHP to know a trigger was called?

I am trying to implement an achievement system in PHP, and MySQL triggers seem to be the best way to track changes to data.

Recommended Answers

All 4 Replies

No, it does not. MySql triggers work on the MySql server only, and do not provide feedback to other applications. Basically, I think it could be possible to write your own user defined function for MySql, but that would be written in C, not in PHP. In PHP you would have to settle for a polling mechanism.

Thought as much, I knew MySQL wouldn't make a call to a PHP script, but I wondered if there was a PHP function like the one that gets the ID of the last inserted row that would tell me if a trigger was run.

Ah well, thanks anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.