well, actually a trigger written in php is not much different from what you would write in a sql environment, yet, it aint working.
What I want is to have inserted 2 different 'id' from 2 different tables into a third table that contains said 'ids' as Foreign Keys. So when I do an insert in both 2 tables, those newly generated ids are also passed on to the 3rd table, to their FK, as I said.
So I sort of go like this
Code: Select all
$sno_id = mysql_insert_id(); // this gets the last generated id and passes it to a variable, and I will use this variable in the query
$trigger = "CREATE TRIGGER pass_the_ids
AFTER INSERT ON second_table
FOR EACH ROW
BEGIN
INSERT INTO the_third_table
NEW.sid = . '$sno_id' .
END;
";
Also you note that I am only passing or trying to pass just one id from one table, havent even tried to do it with 2.