/** * log Import events for importing files * @param string $csv_file * @param boolean $Pass * @param string $Description * @param string $ImportFlag */ function fun_Log_Import($csv_file, $Pass, $Description, $ImportFlag = 0) { global $conn, $intTimeStamp; preg_match("/ftp:\\/\\/(.*)/i", $Site, $arMatch); //just get the URL $Site = $arMatch[1]; //record to log to mysql for web page monitoring $HostID = 1; $Name = "Import {$csv_file}"; $Description = "{$Description}"; $CategoryID = 1033; $Success = $Pass; //1=yes, 0=no $DateCreated = $intTimeStamp; $LastUpdated = $intTimeStamp; //$ImportFlag = 1; //this is to notify the next stage that we are ready to move data //check to see if we need to insert or update? $query = "SELECT MonitorID FROM monitor WHERE (HostID='{$HostID}') AND (Name = '{$Name}')"; $field = "MonitorID"; $rsMonitorID = fun_SQLQuery2($query, $field); if ($rsMonitorID) { $query = "UPDATE monitor SET LastUpdated = '{$LastUpdated}', Success='{$Success}', ImportFlag='{$ImportFlag}', CategoryID='{$CategoryID}'\n\t\t\t WHERE (MonitorID='{$rsMonitorID}'); "; } else { $query = "INSERT INTO monitor (DateCreated, HostID, Name, Description, Success, CategoryID) \n\t\t\t VALUES ('{$DateCreated}', '{$HostID}', '{$Name}', '{$Description}', '{$Success}', '{$CategoryID}');"; } //run the query if ($query) { fun_SQLQuery($query, $WantRC = 0, $WantLID = 1, $rtnRC = "", $rtnLID = "", $arVar = ""); $ImportID = $rtnLID; } return $ImportID; }
/** * 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; }
public function fun_Merge_Status_Directory_Files() { //put all files in active $query = "SELECT * FROM nwmls.image_index WHERE Path like '%sold%'"; $result = fun_SQLQuery($query, $WantRC = 0, $WantLID = 0, $rtnRC = "", $rtnLID = "", $OtherDBConn = "", $arVar = ""); while ($row = mysqli_fetch_object($result)) { $rsPath = $row->Path; $FileName = $row->Name; $rsPath = ereg_replace("/mnt/sas", "", $rsPath); //new directory to move to $LocalBaseDir = $this->LocalBaseDir; $subDirL = $this->fun_getSubDir($FileName, $Remote = 1); $local_file = $LocalBaseDir . $subDirL . "/{$FileName}"; //move file $cmd = "mv {$rsPath} {$local_file}"; echo "{$cmd}\n"; exec($cmd); //update path $query = "UPDATE nwmls.image_index SET Path = '{$local_file}' WHERE (Name = '{$FileName}') "; fun_SQLQuery($query, $WantRC = 0, $WantLID = 0, $rtnRC = "", $rtnLID = "", $OtherDBConn = "", $arVar = ""); } }
/** * transform date into unix timestamp and update the mysql field * @author Brandon Donnelson sept 4 2007 * * @param string $DB * @param string $Sample_Table mysql table * @param string $New_Table_ID * * @returns bol true */ function fun_Mysql_Optimize_Date($DB, $Sample_Table, $New_Table_ID, $Column, $OtherDBConn = "") { if (!$New_Table_ID) { $New_Table_ID = fun_Mysql_getPrimaryKeyColumn($DB, $Sample_Table, $OtherDBConn); } $query = "SELECT {$New_Table_ID}, {$Column} FROM `{$DB}`.`{$Sample_Table}`"; $result = fun_SQLQuery($query, $WantRC = 0, $WantLID = 0, $rtnRC = "", $rtnLID = "", $OtherDBConn = "", $arVar = ""); while ($row = mysqli_fetch_object($result)) { $rsID = $row->{$New_Table_ID}; $rsColumn = $row->{$Column}; $rsColumn = strtotime($rsColumn); $query = "UPDATE `{$DB}`.`{$Sample_Table}` SET {$Column} = '{$rsColumn}' WHERE ({$New_Table_ID} = '{$rsID}')"; echo "DatesToInteger:{$rsColumn} -> {$query}\n"; fun_SQLQuery($query, $WantRC = 0, $WantLID = 0, $rtnRC = "", $rtnLID = "", $OtherDBConn = "", $arVar = ""); } return TRUE; }
/** * 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; }