Sorry for the late answer, but I have no time to do tests with MySQL.
I do test according to your idea (ZDbcMySql.pas):
Code: Select all
{ Sets a client codepage. }
if FClientCodePage <> '' then
begin
{$IFDEF DELPHI12_UP}
SQL := PAnsiChar(UTF8String(Format('SET NAMES ''%s''', [FClientCodePage])));
{$ELSE}
SQL := PAnsiChar(Format('SET NAMES ''%s''', [FClientCodePage]));
{$ENDIF}
FPlainDriver.ExecQuery(FHandle, SQL);
CheckMySQLError(FPlainDriver, FHandle, lcExecute, SQL);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
end;
Code: Select all
procedure TDM.SetPgSQLProperties;
begin
{$IFDEF LINUX}
self.conDB.Properties.Values['codepage']:=codepage;
self.conDB.Properties.Values['client_encoding']:=codepage;
{$ELSE}
{$IFDEF UNICODE}
if DefCodePageID = 65001 then begin
codepage:='utf8';
end else if DefCodePageID = 1250 then begin
codepage:='WIN1250';
end else begin
codepage:='latin2';
end;
self.conDB.Properties.Values['codepage']:='UTF8';
self.conDB.Properties.Values['client_encoding']:=codepage;
{$ELSE}
codepage:='latin2';
self.conDB.Properties.Values['codepage']:=codepage;
self.conDB.Properties.Values['client_encoding']:=codepage;
{$ENDIF}
{$ENDIF}
end;
procedure TDM.SetMySQLProperties;
begin
{$IFDEF LINUX}
self.conDB.Properties.Values['codepage']:=codepage;
self.conDB.Properties.Values['client_encoding']:=codepage;
{$ELSE}
{$IFDEF UNICODE}
if DefCodePageID = 65001 then begin
codepage:='utf8';
end else if DefCodePageID = 1250 then begin
codepage:='CP1250';
end else begin
codepage:='latin2';
end;
self.conDB.Properties.Values['codepage']:=codepage;
self.conDB.Properties.Values['client_encoding']:=codepage;
{$ELSE}
codepage:='latin2';
self.conDB.Properties.Values['codepage']:=codepage;
self.conDB.Properties.Values['client_encoding']:=codepage;
{$ENDIF}
{$ENDIF}
end;
I think we should set the same parameters for all of the databases, or the usage of these parameters are different at different SQL servers!?
Other….
I have a storage and invoice system (compiled with D2010) which based on ZeOS DBO.
This version of the program is running with PostgreSQL in production environment without any problem. But if I do test with MySQL, I have problems with BLOB fields. I can read back images from the database with ZeOS 7.0 (latest SVN TRUNK version) but I could not save correct images into the database. I think the fill of the BLOB filed parameters are wrong. I can you help me to fix it:
Code: Select all
stAsciiStream, stUnicodeStream, stBinaryStream:
begin
TempBlob := DefVarManager.GetAsInterface(Value) as IZBlob;
if not TempBlob.IsEmpty then
Result := GetEscapeString(TempBlob.GetString)
else
Result := 'NULL';
Attila