Advertisement
Guest User

full array loop

a guest
Oct 1st, 2011
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. foreach($sources->Source AS $source):
  2. $PID = null;
  3. //insert/update paper Group as paper if it exists in node
  4. if($source->PaperGroup != ''){
  5. $this->db_interface->setSQL("SELECT * FROM exp_st_papers WHERE Name ='".$source->PaperGroup."'");
  6. $this->db_interface->db_query();
  7. if($this->db_interface->getError()){die('paper group select : '.$this->db_interface->getError());}
  8. $results = $this->db_interface->getResults();
  9. $insertData = array('Name' => $source->PaperGroup, 'Type' => $source->PaperType, 'Status' => $source->PaperStatus);
  10. $this->db_interface->setInsertData($insertData);
  11. $this->db_interface->setWhere(' ID = '.$results->row['ID']);
  12. $this->db_interface->switchTable('exp_st_papers');
  13. //var_dump('paper group num rows: '.$results->row['ID']);
  14. if($results->num_rows == 0){
  15. $this->db_interface->db_insert();
  16. }else{
  17. $this->db_interface->db_update();
  18. }
  19. if($this->db_interface->getError()){die('paper group inser/update : '.$this->db_interface->getError());}
  20. $this->db_interface->setSQl("SELECT * FROM exp_st_papers WHERE Name ='".$source->PaperGroup."'");
  21. $this->db_interface->db_query();
  22. $results = $this->db_interface->getResults();
  23. $PID = $results->row['ID'];
  24. }
  25. //insert/update paper
  26. $this->db_interface->setSQL("SELECT * FROM exp_st_papers WHERE Name ='".$source->PaperName."'");
  27. $this->db_interface->db_query();
  28. $results = $this->db_interface->getResults();
  29. $paperInsertData = array('Name' => $source->PaperName, 'Type' => $source->PaperType, 'Status' => $source->PaperStatus);
  30. $this->db_interface->setInsertData($paperInsertData);
  31. $this->db_interface->switchTable('exp_st_papers');
  32. $this->db_interface->setWhere(' ID = '.$results->row['ID']);
  33. if($results->num_rows == 0){
  34. $this->db_interface->db_insert();
  35. }else{
  36. $this->db_interface->db_update();
  37. }
  38. $this->db_interface->setSQL("SELECT * FROM exp_st_papers WHERE Name ='".$source->PaperName."'");
  39. $this->db_interface->db_query();
  40. $results = $this->db_interface->getResults();
  41. $PaperID = $results->row['ID'];
  42.  
  43. //insert/update sources
  44. $this->db_interface->setSQL("SELECT * FROM exp_st_paper_sources WHERE SourceID =".$source->SourceID);
  45. $this->db_interface->db_query();
  46. $results = $this->db_interface->getResults();
  47. $sourceInsertData = array('SourceName' => $source->SourceName, 'SourceType' => $source->SourceType, 'PaperID' => $PaperID, 'SourceID' => $source->SourceID, 'ValidFrom' => $source->ValidFrom, 'EnqValidTo' => $source->EnqValidTo, 'BkValidTo' => $source->BkgValidTo, 'Brochure' => $source->Brochure, 'Size' => $source->Size, 'MasterTourCode' => $source->MasterTourCode, 'ResponseType' => $source->ResponseType);
  48. $this->db_interface->setInsertData($sourceInsertData);
  49. $this->db_interface->switchTable('exp_st_paper_sources');
  50. $this->db_interface->setWhere(' ID = '.$results->row['ID']);
  51. if($results->num_rows == 0){
  52. $this->db_interface->db_insert();
  53. }else{
  54. $this->db_interface->db_update();
  55. }
  56.  
  57. endforeach;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement