Click here to Skip to main content
15,921,156 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using phpmyadmin.I have a table 'product' with 3 attributes-name|price|date.I need to reset the price to 0 when date < current date(cur_date).I tried using an update query to do the same in my php page which worked,but got other websites too connected to the same db, therefore same update statement has to be written in all of these pages.I would prefer a single step solution for the same which can be done by using trigger but im unaware of how to use it.Could someone pls help me with the query for the same and mention where am i to use the trigger statement in php part or phpmyadmin?
Posted
Comments
PIEBALDconsult 21-Jan-16 0:33am    
Never use triggers.
Sinisa Hajnal 21-Jan-16 5:52am    
Create stored procedure that does what you need to do and call it from scheduled job on the database.

1 solution

You may wish to re-examine what triggers do: CREATE TRIGGER (Transact-SQL)[^]

Therefore, based upon what you wish to do a trigger is not the correct tool. As per the suggestion, above, you really need a job that runs nightly

Some alternatives (not best practices!):

    You may wish to define a function and retrieve the value with the function so that it returns 0 when the value expires.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900