Skip navigation links

MySQL Forums :: Triggers :: Creating a trigger via PHP program


Advanced Search

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
Creating a trigger via PHP program 29075 Brian Schonecker 03/15/2006 01:02PM
Re: Creating a trigger via PHP program 7779 Murz 07/13/2006 05:58AM
Re: Creating a trigger via PHP program 8702 Murz 07/13/2006 06:51AM
Re: Creating a trigger via PHP program 6355 dedy julius 06/01/2007 08:51AM
Re: Creating a trigger via PHP program 6277 Stefan-Andrei Diaconescu 01/31/2008 10:47AM
Re: Creating a trigger via PHP program 5115 Mario Restrepo 04/02/2008 08:53AM


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.