0

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

3
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by pritaeas
0

I want to execute the test.php on server with parameter passed to php

0

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

Edited by tesuji: n/a

0

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

Edited by c_hemant: n/a

0

Again. A stored procedure does not allow any code other than SQL statements. It is not possible to send an email with it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.