Пример #1
0
 private function fun_NWMLS_InsertData($DataType, $arInsert)
 {
     //import db vars
     $tmp_DB = $this->tmp_DB;
     $tmp_Table = $this->tmp_Table_forProcess;
     $ID_Name = $this->fun_NWMLS_getUniqueIDName($DataType);
     //unique id for tmp table for retrieve data
     //my db vars MY TABLE
     $My_Table = $this->fun_NWMLS_getMyTable($DataType);
     $My_DB = $this->My_DB;
     $CountTotal = count($arInsert);
     $Count = $CountTotal;
     //insert records
     foreach ($arInsert as $ID) {
         echo "({$Count} of {$CountTotal}).Inserting[[ID:({$ID})";
         //get the data to insert from the tmp table
         $arData = fun_SQLQuery_InArray($tmp_DB, $tmp_Table, $ID, $OtherDBConn = "", $ID_Name);
         //add DateCreated
         $arData['DateCreated'] = strtotime("now");
         unset($arData['ImportID']);
         //don't need this field
         //debug
         //print_r($arData);
         //Insert the data NOW
         fun_MySQL_Insert_Data($My_DB, $My_Table, $arData, $New_Table_ID = "");
         echo "]]Inserting\n";
         $Count--;
     }
     return TRUE;
 }
Пример #2
0
/**
* compare records - compares Table1 against Table2 like NWMLS_tables to My_tables
* @param string $DB1
* @param string $Table1
* @param string $TableID
* @param string $DB2
* @param string $Table2
* @param string $Table2ID
* @param string $OtherDBConn
*
* @returns mixed $arData3 which is a list of arData[Field] = Value, these are differences of the records
*/
function fun_Mysql_compareRecords($DB1, $Table1, $Table1ID, $ID_Name1, $DB2, $Table2, $Table2ID, $ID_Name2, $OtherDBConn = "")
{
    //debug
    //echo "\nfun_Mysql_compareRecords:[[DB1($DB1), Table1($Table1), Table1ID($Table1ID), IDName1($ID_Name1) - DB2($DB2), Table1($Table2), Table1ID($Table2ID), IDName2($ID_Name2)\n ";
    $arData1 = fun_SQLQuery_InArray($DB1, $Table1, $Table1ID, $OtherDBConn, $ID_Name1);
    //NwmlsData
    $arData2 = fun_SQLQuery_InArray($DB2, $Table2, $Table2ID, $OtherDBConn, $ID_Name2);
    //MyData
    //debug
    //print_r($arData1);
    //print_r($arData2);
    //die("\n\nWORKY????\n");
    foreach ($arData1 as $Field => $Value) {
        //debug
        //echo "checking arData2[$Field]({$arData2[$Field]}) = $Value\n";
        //is it different
        if ($arData2[$Field] != $Value) {
            $arData3[$Field] = $Value;
            //debug
            //echo "value1({$arData2[$Field]}) != value2($Value)\n";
        }
        unset($arData1[$Field]);
        unset($arData2[$Field]);
    }
    //?? (backwards) compare the keys to see if any exists in my table that don't exist in table1?
    //debug
    //die("\nfun_Mysql_compareRecords: early death\n");
    return $arData3;
}