Page 1 of 1

Trigger Substitute

Posted: Thu May 24, 2012 12:17 pm
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

Re: Trigger Substitute

Posted: Sat May 26, 2012 7:30 pm
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;