Hi there,
I'm using the render_sql function to apply a filter to the displayed events and, as such, I have to redefine Insert, Update and Delete logic. I was able to make Update and Delete work correctly, but Insert is another business altogether. The problem is that the ID of the database is never reassigned to the $action object since I have no idea how to do this. Here's what I have so far:
function myInsert($action)
{
global $scheduler;
$requete = "INSERT INTO tblpmtodo (NoClient, NoDivision, Titre, Etiquette, Description, StartDateTime, " .
"EndDateTime, Priorite, ANoPersonne, StatutId, PrcComplete, CalendrierStrategique) VALUES (" .
$action->get_value('NoClient') . ", " . $action->get_value('NoDivision') . ", \"" .
mysql_real_escape_string($action->get_value('Titre')) . "\", \"" .
mysql_real_escape_string($action->get_value('Etiquette')) . "\", \"" .
mysql_real_escape_string($action->get_value('Description')) . "\", \"" .
$action->get_value('StartDateTime') . "\", \"" .
$action->get_value('EndDateTime') . "\", " .
$action->get_value('Priorite') . ", " .
$action->get_value('ANoPersonne') . ", " .
$action->get_value('StatutId') . ", " .
$action->get_value('PrcComplete') . ", " .
$action->get_value('CalendrierStrategique') . ")";
$scheduler->sql->attach("Insert",$requete);
}
$scheduler->event->attach("beforeInsert", "myInsert");
The query I’ve built actually works and the line is indeed added to the tblpmtodo table. The problem comes with events that happen later and that use the get_new_id() function. I got this in the log:
change value of: Etiquette as: TODO - tfilteau - 1291926837887
Which is how I know the id is not the right one. So, how exactly do I reassign the database ID to the $action object so that the get_new_id() function will work as expected?
Thanks in advance.
Osu