Advertisement
Guest User

Untitled

a guest
Jan 10th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. Step1: Select concatenated PK with combined composite key
  2.  
  3. $g->select_command = "SELECT concat(Year_No,'-',Order_No,'-',LocationID,'-',TranscationId) as pk, Year_No, Order_No, LocationID, TranscationId, Startdate, ExpiredDate FROM mylocations ";
  4.  
  5. Step2: Connect on_update event hander
  6. $e["on_update"] = array("update_data", null, false);
  7. $g->set_events($e);
  8.  
  9. Step3: In handler, split the PK with your sep, and make custom UPDATE query
  10. function update_data($data)
  11. {
  12. list($Year_No,$Order_No,$LocationID,$TranscationId) = explode("-",$data["pk"]);
  13.  
  14. $s = array();
  15. foreach($data["params"] as $k=>$v)
  16. {
  17. $s[] = "$k = '$v'";
  18. }
  19. $s = implode(",",$s);
  20.  
  21. $w = "Year_No=$Year_No and Order_No=$Order_No and LocationID=$LocationID and TranscationId=$TranscationId";
  22.  
  23. $result1 = mysql_query("UPDATE mylocations set $s WHERE $w");
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement