Trigger Substitute

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rabastan
Forum Newbie
Posts: 6
Joined: Thu May 24, 2012 12:14 pm

Trigger Substitute

Post by Rabastan »

I have a todo list on my website where I have a field to time stamp when the item was created and one for when the item was completed I planned on using this statement to make that happen.

Code: Select all

CREATE TRIGGER todo_add BEFORE INSERT ON `todo`
FOR EACH ROW SET NEW.date_time = NOW(), NEW.complete_date_time = '0000-00-00 00:00:00';


CREATE TRIGGER todo_complete BEFORE UPDATE ON `todo`
FOR EACH ROW SET NEW.complete_date_time = NOW(), NEW.date_time = OLD.date_time;
I have used it before in the past, however is seems this host wont allow "Triggers" in mysql. My question is how can I do this same thing using PHP.

Rab
Last edited by Rabastan on Thu May 24, 2012 2:50 pm, edited 1 time in total.
DevlshOne
Forum Newbie
Posts: 2
Joined: Sat May 26, 2012 7:16 pm

Re: Trigger Substitute

Post by DevlshOne »

It sounds like your solution would be using the Date functions in PHP. Perhaps something like this..

Code: Select all

function itemCreated()
.....code....
$tstamp_created = date('Y-m-d H:i:s',time());
return $tstamp_created;

function itemComplete()
.......code.....
$tstamp_completed = date('Y-m-d H:i:s', time());
return $tstamp_completed;
Post Reply