Hi All,
I am trying to Create the trigger which will invoke the php after record is field in record is updated.
Can anyone please help me with some sample code
Regards
Hemant
A database trigger cannot execute PHP code, only SQL statements.
I want to execute the test.php on server with parameter passed to php
As pritaeas already explained trigger cannot consist of PHP code. There are only SQL and PSM (Persistent Storage Modul, yes, that's a standardized procedural programming language, not only like Oracle's pl/sql but partly derived from it) allowed within a trigger. You may consult SQL standard 2003.
Java, C, C++ or even PHP are not allowed until today. In the not-that-far future there could be triggers written in Java because Java has been designated to be the new procedural programming language for SQL. This important arrangement was made in the SQL standardization of 2003.
However, one can create a trigger fom within PHP5 using multi_query(string) as for instance:
/* Trigger example for MS SQL Server, Oracle, Sybase
Below trigger sample is based on standard 2003 PSM. Proprietary database systems, for instance MySQL, may have their own token and syntax or may plain omit some standarized PSM features.
*/
$sql="CREATE TRIGGER myTrigger AFTER INSERT, UPDATE, DELETE ON myTable
REFERENCING OLD AS oRow NEW AS nRow
FOR EACH ROW
BEGIN
IF INSERTING THEN
BEGIN
-- Do something dealing with inserted data
END
ELSEIF UPDATING THEN
BEGIN
-- Do something dealing with updated data
END
ELSEIF DELETING THEN
BEGIN
-- Do something dealing with deleted data
END
END IF;
END;"
$mysqli->multi_query($sql)
-- tesu
hi tesu,
How can i send Email using the MYSQL, i do not want to use the PHP use triggers will try and fire the Stored Procedure to send out a mail.
Many Thanks
-------->Hemant
Again. A stored procedure does not allow any code other than SQL statements. It is not possible to send an email with it.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.