Witam,
mam poniższą klasę do zrzutu bazy MySQL do pliku, wszystko ładnie działa, ale mam problem z polskimi ogonkami "ą", "ź", "ś" - wpisuje mi krzaki, proszę o podpowiedź
.....
function createDump() {
// Set line feed
$lf = "\n";
$resource = mysql_connect($this->getHost(), $this->getDBuser(), $this->getDBpassword()); $tables = $this->result2Array(0, $result);
foreach ($tables as $tblval) {
$createtable[$tblval] = $this->result2Array(1, $result);
}
// Set header
$output = "#". $lf;
$output .= "# DUmp" . $lf;
$output .= "# Version 2.6" . $lf;
$output .= "# ". $lf;
$output .= "# Host: " . $this->getHost() . $lf;
$output .= "# Czas wygenerowania: " . date("M j, Y at H:i") . $lf; $output .= "# Baza danych : `" . $this->getDBname() . "`" . $lf;
$output .= "#";
// Generate dumptext for the tables.
foreach ($tables as $tblval)
{
If (($tblval!="bip_logowanie") and ($tblval!="bip_users"))
{
$output .= $lf . $lf . "# --$tabela------------------------------------------------------" . $lf . $lf;
$output .= "#". $lf . "# Struktura tabeli dla `$tblval`" . $lf;
$output .= "#" . $lf . $lf;
// Generate DROP TABLE statement when client wants it to.
if($this->isDroptables())
{
$output .= "DROP TABLE IF EXISTS `$tblval`;" . $lf;
}
$output .= $createtable[$tblval][0].";" . $lf;
$output .= $lf;
$output .= "#". $lf . "# Zrzut danych tabeli `$tblval`". $lf . "#" . $lf;
$rows = $this->loadObjectList("", $result);
foreach($rows as $row)
{
$insertdump = $lf;
$insertdump .= "INSERT INTO `$tblval` VALUES (";
$arr = $this->object2Array($row);
foreach($arr as $key => $value)
{
//$value = str_replace("n", 'rn', $value);
//$value = str_replace("r", '', $value);
$insertdump .= "'$value',";
}
$output .= rtrim($insertdump,',') . ");"; }
}
}
return $output;
}
// Private function object2Array.
function object2Array($obj) {
$array = null;
foreach (get_object_vars($obj) as $key => $value) {
$array[$key] = $this->object2Array($value);
else
$array[$key] = $value;
}
}
return $array;
}
// Private function loadObjectList.
function loadObjectList($key='', $resource) {
if ($key)
$array[$row->$key] = $row;
else
$array[] = $row;
}
return $array;
}
// Private function result2Array.
function result2Array($numinarray = 0, $resource) {
$array[] = $row[$numinarray];
}
return $array;
}
}
.....