Page 1 of 1

afterSave syntax

PostPosted: Mon Nov 03, 2008 8:25 am
by fauners
Hi all,
I have a question regarding the use of afterSave in the delegate class, I;m pretty new to all this so i know i'm going wrong somewhere, just dont know where.
I have two related tabled and a join table, Employees, events and employeeEvents, I can add individuals to certain events and vice versa fine but i am trying to be able to batch update a selection of employees to a certain event so i thought using aftersave would be the best approach.

I have a field in employees that mirrors the event id in employeeEvents, so i'm trying to update several employees by changing this field then change the join table by aftersave. this is the code I tred, with some slight modifications but i couldnt get it working, I just think i have the sytax wrong.
Code: Select all

<class>db());
}
}
?>

Any help would be great? or am I taking a completely stupid way round this and there is an obvious solution staring me in the face?

Thanks n advance,

Adam

PostPosted: Mon Nov 03, 2008 8:27 am
by fauners
Sorry here is the code, got cut off there

Code: Select all
<?
class tables_Employees {

function afterSave(&$record){

$app =& Dataface_Application::getInstance();
$res = mysql_query("REPLACE EmployeeEvents (EmployeeID, event_id) SELECT ID, event_id FROM Employees}'", $app->db());
}
}
?>

PostPosted: Wed Nov 05, 2008 8:27 am
by shannah
How are you making this "selection" of employees that you want to add to the event?

-Steve

PostPosted: Wed Nov 05, 2008 9:33 am
by fauners
Hi steve,

I wanted to select employees in the employee area and then "update set" to a certain event. At the moment i can only add one at a time either through the add existing employees record in the events section or add existing event to an employee in the employee section.

I would like to be able to select a large number of employees and add them to an event, instead of one by one. I have tried other ways but i cant seem to figure out how to get it done.

Any ideas how best to do this?

Thanks,

Adam

PostPosted: Wed Nov 05, 2008 11:47 am
by shannah
This sounds like something that you'll want to create a custom action for. There's many ways that you can do this.. I can't go into too much detail right now, but you should be able to find some information in tutorials on how to get started with custom actions.