+ Adapted to version 4 of mysql

This commit is contained in:
michael 2004-09-29 20:26:48 +00:00
parent 15d3388449
commit 98f8032223

View File

@ -237,22 +237,22 @@ begin
for I := 0 to FC-1 do for I := 0 to FC-1 do
begin begin
fld := mysql_fetch_field_direct(FMYSQLRES, I); fld := mysql_fetch_field_direct(FMYSQLRES, I);
if Field.FieldName = fld.name then if Field.FieldName = fld^.name then
begin begin
Move(CurBuf^, PChar(Buffer)^, MySQLDataSize(fld.ftype, fld.length)); Move(CurBuf^, PChar(Buffer)^, MySQLDataSize(fld^._type, fld^.length));
if Field.DataType in [ftString{, ftWideString}] then if Field.DataType in [ftString{, ftWideString}] then
begin begin
Result := PChar(buffer)^ <> #0; Result := PChar(buffer)^ <> #0;
if Result then if Result then
// Terminate string (necessary for enum fields) // Terminate string (necessary for enum fields)
PChar(buffer)[fld.length] := #0; PChar(buffer)[fld^.length] := #0;
end end
else else
Result := True; Result := True;
break; break;
end end
else else
Inc(CurBuf, MySQLDataSize(fld.ftype, fld.length)); Inc(CurBuf, MySQLDataSize(fld^._type, fld^.length));
end; end;
end; end;
@ -374,8 +374,8 @@ begin
for I := 0 to FC-1 do for I := 0 to FC-1 do
begin begin
field := mysql_fetch_field_direct(FMYSQLRES, I); field := mysql_fetch_field_direct(FMYSQLRES, I);
if MySQLFieldToFieldType(field.ftype, field.length, DFT, DFS) then if MySQLFieldToFieldType(field^._type, field^.length, DFT, DFS) then
TFieldDef.Create(FieldDefs, field.name, DFT, DFS, False, I+1); TFieldDef.Create(FieldDefs, field^.name, DFT, DFS, False, I+1);
end; end;
finally finally
if WasClosed then if WasClosed then
@ -523,7 +523,7 @@ begin
for I := 0 to FC-1 do for I := 0 to FC-1 do
begin begin
field := mysql_fetch_field_direct(FMYSQLRES, I); field := mysql_fetch_field_direct(FMYSQLRES, I);
FRecordSize := FRecordSize + MySQLDataSize(field.ftype, field.length); FRecordSize := FRecordSize + MySQLDataSize(field^._type, field^.length);
end; end;
FBufferSize := FRecordSize + SizeOf(TMySQLDatasetBookmark); FBufferSize := FRecordSize + SizeOf(TMySQLDatasetBookmark);
end; end;
@ -544,7 +544,7 @@ begin
for I := 0 to FC-1 do for I := 0 to FC-1 do
begin begin
field := mysql_fetch_field_direct(FMYSQLRES, I); field := mysql_fetch_field_direct(FMYSQLRES, I);
CT := MySQLWriteFieldData(field.ftype, field.length, row^, Buffer); CT := MySQLWriteFieldData(field^._type, field^.length, row^, Buffer);
Inc(Buffer, CT); Inc(Buffer, CT);
Inc(row); Inc(row);
end; end;
@ -824,10 +824,13 @@ Var
H,U,P : String; H,U,P : String;
begin begin
if (FMySQL=Nil) then
New(FMySQL);
H:=HostName; H:=HostName;
U:=UserName; U:=UserName;
P:=Password; P:=Password;
FMySQL:=mysql_connect(FMySQL,PChar(H),PChar(U),Pchar(P)); mysql_init(FMySQL);
FMySQL:=mysql_real_connect(FMySQL,PChar(H),PChar(U),Pchar(P),Nil,0,Nil,0);
If (FMySQL=Nil) then If (FMySQL=Nil) then
MySQlError(Nil,SErrServerConnectFailed,Self); MySQlError(Nil,SErrServerConnectFailed,Self);
FServerInfo := strpas(mysql_get_server_info(FMYSQL)); FServerInfo := strpas(mysql_get_server_info(FMYSQL));
@ -877,8 +880,8 @@ begin
if Disconnect then if Disconnect then
ConnectToServer; ConnectToServer;
try try
if mysql_create_db(FMySQL,Pchar(DatabaseName))<>0 then {if mysql_create_db(FMySQL,Pchar(DatabaseName))<>0 then
MySQLError(FMySQL,SErrDatabaseCreate,Self); MySQLError(FMySQL,SErrDatabaseCreate,Self);}
Finally Finally
If Disconnect then If Disconnect then
DoInternalDisconnect; DoInternalDisconnect;
@ -897,8 +900,10 @@ begin
If (FMySQL=Nil) then If (FMySQL=Nil) then
ConnectToServer; ConnectToServer;
try try
{
if mysql_drop_db(FMySQL,Pchar(DatabaseName))<>0 then if mysql_drop_db(FMySQL,Pchar(DatabaseName))<>0 then
MySQLError(FMySQL,SErrDatabaseDrop,Self); MySQLError(FMySQL,SErrDatabaseDrop,Self);
}
Finally Finally
If Disconnect then If Disconnect then
DoInternalDisconnect; DoInternalDisconnect;
@ -916,7 +921,10 @@ end.
{ {
$Log$ $Log$
Revision 1.5 2004-09-20 07:13:38 michael Revision 1.6 2004-09-29 20:26:48 michael
+ Adapted to version 4 of mysql
Revision 1.5 2004/09/20 07:13:38 michael
+ Database property published + Database property published
Revision 1.4 2003/08/16 16:42:21 michael Revision 1.4 2003/08/16 16:42:21 michael