Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Invoice | Dealer | Rep | quantity | Frame | Cover | Color | Placements | shipdate
- ---------------------------------------------------------------------------------
- 100 123 250 1 1234 12 1 2 20180219
- 101 321 250 1 1235 12 1 2 20180219
- 102 432 250 1 1236 12 1 2 20180219
- ID | Frame | GroupID | cover | color
- ------------------------------------
- 15 1234 1 12 1
- 16 1235 2 12 1
- 17 1236 3 12 1
- sku_id | groupID | dealerID | startDate | expirationDate | placements
- ------------------------------------------------------------------------------
- 15 1 123 20180226 (shipdate + 127 days) 2
- 16 2 123 20180226 (shipdate + 127 days) 2
- 17 3 123 20180226 (shipdate + 127 days) 2
- <?php
- //MySql Connection credentials
- $mysqlServer = "";
- $mysqlUser = "";
- $mysqlPass = "*";
- //Establilsh MySql Connection
- $mysqlConn = new mysqli($mysqlServer, $mysqlUser, $mysqlPass);
- //Check MySQL connection
- if($mysqlConn->connect_error){
- die("Connection Failed: " .$mysqlConn->connect_error);
- }
- echo "Connected Succssfully to Mysql";
- try {
- $DB2Conn = odbc_connect("","", "");
- if(!$DB2Conn){
- die("Could not connect");
- }else{
- echo"Connected to DB2";
- }
- $plcQueryDB2 = "
- select invnoc AS INVOICE,
- cstnoc AS DEALER,
- slsnoc AS REP,
- orqtyc AS QUANTITY,
- framec AS FRAME,
- covr1c AS COVER,
- colr1c AS COLOR ,
- SUM(skunoc) as PLACEMENTS,
- extd1d AS SHIPDATE
- FROM GPORPCFL
- group by invnoc,cstnoc, slsnoc, orqtyc, framec, covr1c,colr1c, extd1d
- ";
- $prep = odbc_prepare($DB2Conn, $plcQueryDB2);
- $exec = odbc_execute($prep);
- $result = odbc_exec($DB2Conn, $plcQueryDB2);
- }
- catch(Exception $e) {
- echo $e->getMessage();
- }
- //Put $result into array chunk, process records in hundreds, possibly by 200 at a time
- //Logic for the query results Insert/ Upsert
- //This is pseudo code
- 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
- $insertsql = "
- ";
- }
Add Comment
Please, Sign In to add comment