IT Community - Software Programming, Web Development and Technical Support

how to create trigger in MYSQL

This is a discussion on how to create trigger in MYSQL within the Database Support forums, part of the Web Development category; HI, how to create trigger in MySql using PHP?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-08-2007, 05:18 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default how to create trigger in MYSQL

HI,
how to create trigger in MySql using PHP?
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-08-2007, 07:00 AM
write2ashokkumar write2ashokkumar is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 85
write2ashokkumar is on a distinguished road
Default Re: how to create trigger in MYSQL

hi...

"How to create trigger in Mysql?" - Is this your question?

Regards,
S.Ashokkumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-09-2007, 01:23 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: how to create trigger in MYSQL

Hi Ashok,
Is there any possibilty that we have fire triggers in PHP?
Ok. First we have to start with creation of triggers in MySql. Do you have any idea about creating trigger in MySql?
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-09-2007, 06:21 AM
write2ashokkumar write2ashokkumar is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 85
write2ashokkumar is on a distinguished road
Default Re: how to create trigger in MYSQL

hi...

A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table.

To know more about the trigger, reffer the following link.

MySQL AB :: MySQL 5.0 Reference Manual :: 18 Triggers

Regards,
S.Ashokkumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-10-2007, 02:55 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: how to create trigger in MYSQL

hi,
Thanks for your reply. But i think we can execute of creating triggers in PHP script is itself

For example,

$query = "CREATE TRIGGER ins_sum BEFORE INSERT ON account
FOR EACH ROW SET @sum = @sum + NEW.amount;";

mysql_query($query);

is it possible?
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-10-2007, 11:53 PM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Re: how to create trigger in MYSQL

PHP Code:
<?php
// Opening a MYSQL Connection
$vConnection mysql_connect('Local Host IP''UserName''Password');
// Executing the Query 
$vQuery mysql_query("CREATE TRIGGER ins_sum BEFORE INSERT ON account FOR EACH ROW SET @sum = @sum + NEW.amount;END;");
mysql_query($vQuery);
// Closing the Connection
mysql_close($vConnection);
?>
Creating a Trigger is very simple as executing a Query.

I have marked the Syntax error in the Stated Query

$query = "CREATE TRIGGER ins_sum BEFORE INSERT ON account
FOR EACH ROW SET @sum = @sum + NEW.amount;END;";
mysql_query($query);
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setup a clock with defined alarm times which trigger another event itbarota HTML, CSS and Javascript Coding Techniques 1 03-04-2008 09:57 PM
How to create UDF function in Mysql Murali Database Support 1 12-01-2007 02:03 AM
Can we have a commit statement inside a trigger? if no why cant we? Mramesh Database Support 6 09-11-2007 03:08 AM
Run an exe from an oracle trigger H2o Database Support 5 08-09-2007 11:55 AM
Storing the output from trigger in a text file sureshbabu Database Support 3 07-27-2007 06:44 AM


All times are GMT -7. The time now is 09:02 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0