18 wrz 2009

Dump i import tabeli mysql w php

dump:

$command = 'mysqldump -h localhost -B baza -u user -phaslo --tables Panstwa --no-create-info --skip-lock-tables --compact --comments --complete-insert > /data/dump/Panstwa.sql 2> /data/dump/err_Panstwa.txt';
exec($command);

import:

$command = 'mysql -h localhost -B baza -u user -phaslo --default-character-set=utf8 < /data/dump/Panstwa.sql';
exec($command);

kopiownie:

$sql = 'INSERT INTO Panstwa SELECT * FROM b_Panstwa';
mysql_query($sql);
11 maj 2009

konwersja utf8 na katakana

sub UTF8toKatakana
# convert utf8 to katakana
{
my ( $stri ) = @_;

$stri =~ s/\xC4\x85/a/g;    # ą
$stri =~ s/\xC4\x84/A/g;    # Ą
$stri =~ s/\xC4\x87/c/g;    # ć
$stri =~ s/\xC4\x86/C/g;    # Ć
$stri =~ s/\xC4\x99/e/g;    # ę
$stri =~ s/\xC4\x98/E/g;    # Ę
$stri =~ s/\xC5\x82/l/g;    # ł
$stri =~ s/\xC5\x81/L/g;    # Ł
$stri =~ s/\xC3\xB3/o/g;    # ó
$stri =~ s/\xC3\x93/O/g;    # Ó
$stri =~ s/\xC5\x9B/s/g;    # ś
$stri =~ s/\xC5\x9A/S/g;    # Ś
$stri =~ s/\xC5\xBC/z/g;    # ż
$stri =~ s/\xC5\xBB/Z/g;    # Ż
$stri =~ s/\xC5\xBA/z/g;    # ź
$stri =~ s/\xC5\xB9/Z/g;    # Ź
$stri =~ s/\xc5\x84/n/g;    # ń
$stri =~ s/\xc5\x83/N/g;    # Ń

return $stri;
}
&UTF8toKatakana($calosc);