MySQL Forums
Forum List  »  Triggers

Re: Creating a trigger via PHP program
Posted by: Murz
Date: July 13, 2006 06:51AM

Do it like this with mysqli php extension:
<?php
$db=new mysqli($host, $user, $password, $db);
$trigger="CREATE TRIGGER trigger1 BEFORE INSERT ON table1
FOR EACH ROW
BEGIN
IF NEW.VALUE1 = 1 THEN
SET NEW.VALUE2 = 'one';
ELSEIF NEW.VALUE1 = 2 THEN
SET NEW.VALUE2 = 'two';
END IF;
END;
";
$db->multi_query($trigger);
?>

Options: ReplyQuote


Subject
Views
Written By
Posted
8574
July 13, 2006 05:58AM
Re: Creating a trigger via PHP program
16945
July 13, 2006 06:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.