/** * 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; }
function endHandler($parser, $name) { global $Count, $arData, $Name, $CountNodes; //debug //echo "$Count.$name\n"; $Node = $this->CVSNode; if (preg_match("/\\b{$Node}\\b/i", $name)) { echo "\n({$CountNodes})Class_xml2mysql:(CurrentNode:({$Node}),MyNode:({$name})-> Inserting:[["; //insert mysql data $LastID = fun_MySQL_Insert_Data($this->DB, $this->New_Table, $arData); $arData = ""; //reset this var for new node //add custom field on insert of data, so to mark it for other uses if ($this->AddCustomField) { $AddCustomField = $this->AddCustomField; $ID_Name = fun_Mysql_getPrimaryKeyColumn($this->DB, $this->New_Table, $OtherDBConn = ""); $arData[$ID_Name] = "{$LastID}"; $arData[$AddCustomField] = "1"; fun_Mysql_Update_Data($this->DB, $this->New_Table, $arData, $ID_Name = "", $rtnError = ""); $arData = ""; } echo "]]\n"; $CountNodes++; } }
/** * 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; }