Hi all,
I'm sorry to keep posting questions, I'm hoping this will be the last one
Basically I'm stuck again - what I'm trying to do is:
Upon adding something to a table I want to be able to automatically add a new entity to other tables
I figure this is a trigger, however I'm not sure how I use the dataface api to do it... I'm sure this isn't the first time something like this
function afterInsert(&$record){
// Enter the code here
}
my php i wrote to do this before was:
// insert data into db:
$insert = db_query('
INSERT INTO EPISODES
(
MATRIX_ID, EPISODE_TITLE, EPISODE_BLURB
)
VALUES
(
?, ?, ?
)',
$commandID,
"New Episode Title",
"Enter the new episode description here") or die("Error in insertion: " . mysql_error());
$epid = mysql_insert_id();
$insert = db_query('
INSERT INTO MATRIX_EPISODE_ITEM
(
EPISODE_NUMBER, ITEM_ID, ITEM_DESC
)
SELECT
EPISODE_NUMBER, ITEM_ID, ""
FROM
EPISODES, MATRIX_ITEM
WHERE
EPISODES.MATRIX_ID=MATRIX_ITEM.MATRIX_ID AND
EPISODES.EPISODE_NUMBER=?',
$epid) or die("Error in insertion: " . mysql_error());
echo("New episode $commandID $epid created.
");
This just creates a new episode and then creates a new "matrix_episode_item" for each item in the system that belongs to the same series (matrix)
I figure I need to embed this into the trigger, but for the life of mye I have no idea of an elegant solution for this.
Again, all help is greatly appreciated