private function fun_NWMLS_Process_NewRecords($DataType) { //import db vars $tmp_DB = $this->tmp_DB; $tmp_Table = $this->tmp_Table_forProcess; //$this->tmp_Table; $ID_Name = $this->fun_NWMLS_getUniqueIDName($DataType); //unique id for tmp table for retrieve data //debug echo "fun_NWMLS_Process_NewRecords:tmp_DB({$tmp_DB}),tmp_Table({$tmp_Table}),ID_Name({$ID_Name}),DataType({$DataType})\n"; //get columns of tmp db $arColumns = fun_Mysql_getColumns($tmp_Table, $tmp_DB); //Go through the new records I just imported into mysql tmp table $query = "SELECT * FROM `{$tmp_DB}`.`{$tmp_Table}`"; //echo "fun_NWMLS_Process_NewRecords:checking records $query\n"; $result = fun_SQLQuery($query, $WantRC = 1, $WantLID = 0, $rtnRC, $rtnLID = "", $OtherDBConn = "", $arVar = ""); $Count = $rtnRC; while ($row = mysqli_fetch_object($result)) { $rsID = $row->{$ID_Name}; //get the new ids that i just imported echo "({$Count} of {$rtnRC}). Checking ID:({$rsID})[[ "; //build list of what to do with each UniqueID $Modify = $this->fun_NWMLS_checkExistInMyTable($DataType, $rsID); if ($Modify == "Update") { $arUpdate[] = $rsID; } else { $arInsert[] = $rsID; } echo " ]]:Checking ID\n"; $Count--; } //PROCESS RECORD NOW //insert record if ($arInsert) { echo "InsertDif::[["; $this->fun_NWMLS_InsertData($DataType, $arInsert); echo "]]::InsertDif"; } //update record if ($arUpdate) { echo "UpdateDif::[["; $this->fun_NWMLS_UpdateData($DataType, $arUpdate); echo "]]::UpdateDif"; } //debug //echo "arInsert\n"; //print_r($arInsert); //echo "arUpdate\n"; //print_r($arUpdate); $ctarInsert = count($arInsert); $ctarUpdate = count($arUpdate); //debug //die("\n\nfun_NWMLS_Process_NewRecords: before optimize\n\n"); //Won't always need this here!! //make sure we have an optimized list if ($ctarInsert > 0 or $ctarUpdate > 0) { echo "\n\n Optimize::\n\n"; $My_Table = $this->fun_NWMLS_getMyTable($DataType); $My_DB = $this->My_DB; //fun_Mysql_Optimize_Columns($My_DB, $My_Table, $Test_HowMany_Rows=1500); } else { echo "\n\nSkipping optimizing My_Table({$My_Table}) ctarInsert({$ctarInsert}) ctarUpdate({$ctarUpdate})\n\n "; } }
/** * get a record like arData[field] = value * @param string $DB * @param stinrg $Table * @param string $ID * * @returns array $arData like arData[field] = value */ function fun_SQLQuery_InArray($DB, $Table, $ID, $OtherDBConn = "", $OtherIDName = "") { global $conn; //debug //echo "\nfun_SQLQuery_InArray[[Table($Table)"; if ($Table) { if (!$OtherIDName) { $PriKeyName = fun_Mysql_getPrimaryKeyColumn($DB, $Table, $OtherDBConn); //get primary id name } else { $PriKeyName = $OtherIDName; } $query = "SELECT * FROM `{$DB}`.`{$Table}` WHERE ({$PriKeyName} = '{$ID}')"; //debug //echo "query:($query)"; $arColumns = fun_Mysql_getColumns($Table, $DB); //get columns $result = fun_SQLQuery($query, $WantRC = 0, $WantLID = 0, $rtnRC = "", $rtnLID = "", $OtherDBConn, $arVar = ""); while ($row = mysqli_fetch_object($result)) { foreach ($arColumns as $field) { $arData[$field] = $row->{$field}; } } //end while(rs) } //if query //debug //echo "]]fun_SQLQuery_InArray\n"; return $arData; }
/** * get 1 row of data by unique id in array * @author Brandon Donnelson sept 4 2007 2:12am * @param string $DB * @param string $Table table to get row of data from * @param string $ID unique id that designates the row * @returns array $arData['key'] and $arData['value'] * */ function fun_Mysql_getRowData($DB, $Table, $ID) { //debug //echo "fun_Mysql_getRowData: $DB, $Table, $ID\n"; $Name_ID = fun_Mysql_getPrimaryKeyColumn($DB, $Table, $OtherDBConn); $arColumns = fun_Mysql_getColumns($Table, $DB); $query = "SELECT * FROM `{$DB}`.`{$Table}` WHERE ({$Name_ID} = '{$ID}')"; $result = fun_SQLQuery($query, $WantRC = 0, $WantLID = 0, $rtnRC = "", $rtnLID = "", $OtherDBConn = "", $arVar = ""); while ($row = mysqli_fetch_object($result)) { foreach ($arColumns as $Field) { $arData[$Field] = $row->{$Field}; } } return $arData; }