Guest User

Untitled

a guest
Feb 23rd, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. Invoice | Dealer | Rep | quantity | Frame | Cover | Color | Placements | shipdate
  2. ---------------------------------------------------------------------------------
  3. 100 123 250 1 1234 12 1 2 20180219
  4. 101 321 250 1 1235 12 1 2 20180219
  5. 102 432 250 1 1236 12 1 2 20180219
  6.  
  7. ID | Frame | GroupID | cover | color
  8. ------------------------------------
  9. 15 1234 1 12 1
  10. 16 1235 2 12 1
  11. 17 1236 3 12 1
  12.  
  13. sku_id | groupID | dealerID | startDate | expirationDate | placements
  14. ------------------------------------------------------------------------------
  15. 15 1 123 20180226 (shipdate + 127 days) 2
  16. 16 2 123 20180226 (shipdate + 127 days) 2
  17. 17 3 123 20180226 (shipdate + 127 days) 2
  18.  
  19. <?php
  20.  
  21. //MySql Connection credentials
  22. $mysqlServer = "";
  23. $mysqlUser = "";
  24. $mysqlPass = "*";
  25.  
  26. //Establilsh MySql Connection
  27. $mysqlConn = new mysqli($mysqlServer, $mysqlUser, $mysqlPass);
  28.  
  29. //Check MySQL connection
  30. if($mysqlConn->connect_error){
  31. die("Connection Failed: " .$mysqlConn->connect_error);
  32. }
  33. echo "Connected Succssfully to Mysql";
  34.  
  35. try {
  36. $DB2Conn = odbc_connect("","", "");
  37.  
  38. if(!$DB2Conn){
  39. die("Could not connect");
  40. }else{
  41. echo"Connected to DB2";
  42. }
  43.  
  44. $plcQueryDB2 = "
  45.  
  46. select invnoc AS INVOICE,
  47. cstnoc AS DEALER,
  48. slsnoc AS REP,
  49. orqtyc AS QUANTITY,
  50. framec AS FRAME,
  51. covr1c AS COVER,
  52. colr1c AS COLOR ,
  53. SUM(skunoc) as PLACEMENTS,
  54. extd1d AS SHIPDATE
  55. FROM GPORPCFL
  56. group by invnoc,cstnoc, slsnoc, orqtyc, framec, covr1c,colr1c, extd1d
  57.  
  58. ";
  59.  
  60. $prep = odbc_prepare($DB2Conn, $plcQueryDB2);
  61. $exec = odbc_execute($prep);
  62. $result = odbc_exec($DB2Conn, $plcQueryDB2);
  63. }
  64. catch(Exception $e) {
  65. echo $e->getMessage();
  66. }
  67.  
  68.  
  69. //Put $result into array chunk, process records in hundreds, possibly by 200 at a time
  70.  
  71. //Logic for the query results Insert/ Upsert
  72. //This is pseudo code
  73. if ($row['placements'] < count){ //Here, I am iterating to ensure that there are only as many records inserted as there are placements. 3 placements = 3 records
  74.  
  75. $insertsql = "
  76.  
  77. ";
  78. }
Add Comment
Please, Sign In to add comment