Inserting updating and deleting data to mysql through php

6854933580_2c8b688306_z

A trigger is a named database object that is associated with a table, and it activates when a particular event (e.g. The statement CREATE TRIGGER creates a new trigger in My SQL.Here is the syntax : Syntax: Explanation: DEFINER clause: The DEFINER clause specifies the My SQL account to be used when checking access privileges at trigger activation time.After establishing a connection to the My SQL and its specific database, it is time to work with the database records.Mostly, we need to insert, update, retrieve and delete records from the database tables.trigger_body: trigger_body is the statement to execute when the trigger activates. Here is a simple example: A column named with OLD is read only.You can refer to it (if you have the SELECT privilege), but not modify it.If a user value is given, it should be a My SQL account specified as 'user_name'@'host_name' (the same format used in the GRANT statement), CURRENT_USER, or CURRENT_USER().The default DEFINER value is the user who executes the CREATE TRIGGER statement.

trigger_event: trigger_event indicates the kind of operation that activates the trigger.You can refer to a column named with NEW if you have the SELECT privilege for it.In a BEFORE trigger, you can also change its value with SET NEW.col_name = value if you have the UPDATE privilege for it.My SQL Triggers We assume that you are habituated with "My SQL Stored Procedures", if not you can read our My SQL Procedures tutorial.You can use the following statements of My SQL procedure in triggers: How to create My SQL triggers?These trigger_event values are permitted: tbl_name : The trigger becomes associated with the table named tbl_name, which must refer to a permanent table.

You must have an account to comment. Please register or login here!