CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 modifying SQL in BEFORE EXECUTE UPDATE event

Print topic Send  topic

Author Message
jdojr

Posts: 6
Posted: 01/28/2008, 8:10 PM

I am having a tough time using the right custom code to modify the SQL UPDATE statement in the BEFORE EXECUTE UPDATE EVENT.

Could anyone give me an idea of what the code should look like ?

If you need more detail, the more complete description is here -

http://forums.yessoftware.com/posts.php?post_id=93364

Thanks !


_________________
J Osterman
View profile  Send private message
jdojr

Posts: 6
Posted: 02/02/2008, 5:23 PM

Well, I finally came up with a solution...it might not be the best, and maybe it may be breakable under actual use, but I'll include an example that here that works, in case anyone else is ever wondering about this in the future.

//prog_grp_sessions_ds_BeforeExecuteUpdate @5-6B97373A  
function prog_grp_sessions_ds_BeforeExecuteUpdate(& $sender)  
{  
    $prog_grp_sessions_ds_BeforeExecuteUpdate = true;  
    $Component = & $sender;  
    $Container = & CCGetParentContainer($sender);  
    global $prog_grp_sessions; //Compatibility  
//End prog_grp_sessions_ds_BeforeExecuteUpdate  
  
//Custom Code @59-2A29BDB7  
// -------------------------  
  
$key_1=$prog_grp_sessions->session_id->GetValue(True);  
$key_2=$prog_grp_sessions->grp_member_id->GetValue(True);  
$key_3=$prog_grp_sessions->record_status->GetValue(True);  
  
$value_1=$prog_grp_sessions->cb_attended->GetValue(True);  
$value_2=$prog_grp_sessions->tb_fee_paid->GetValue(True);  
$value_3=$prog_grp_sessions->tb_note->GetValue(true);  
  
if ($value_1<>1) {$value_1=0;}  
  
if ($key_3==1) {  
  
  $prog_grp_sessions->DataSource->SQL="UPDATE prog_grp_sessions_attendance SET attended=".$value_1.", fee_paid=".$value_2.", note='".$value_3."' WHERE grp_session_id=".$key_1." AND grp_member_id=".$key_2."";  
  
}  
  
else {  
  
  $key_4=1;  
  
  $prog_grp_sessions->DataSource->SQL="INSERT INTO prog_grp_sessions_attendance(grp_session_id, grp_member_id, attended, note, record_status, fee_paid) VALUES('".$key_1."', '".$key_2."', '".$value_1."', '".$value_3."', '".$key_4."', '".$value_2."')";  
  
}  
  
  
// -------------------------  
//End Custom Code

_________________
J Osterman
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.