mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 01:39:27 +02:00
+ Fixes in TDBDataset etc. Changed MySQLDb to use database as well
This commit is contained in:
parent
df1fa8669a
commit
2e6d07b89e
@ -66,6 +66,8 @@ constructor TDatabase.Create(AOwner: TComponent);
|
||||
|
||||
begin
|
||||
Inherited Create(AOwner);
|
||||
FParams:=TStringlist.Create;
|
||||
FDatasets:=TList.Create;
|
||||
end;
|
||||
|
||||
destructor TDatabase.Destroy;
|
||||
@ -74,6 +76,7 @@ begin
|
||||
Connected:=False;
|
||||
RemoveDatasets;
|
||||
FDatasets.Free;
|
||||
FParams.Free;
|
||||
Inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -173,9 +176,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TDBDataset.CheckDatabase;
|
||||
|
||||
begin
|
||||
If (FDatabase=Nil) then
|
||||
DatabaseError(SErrNoDatabaseAvailable,Self)
|
||||
end;
|
||||
|
||||
Destructor TDBDataset.Destroy;
|
||||
|
||||
begin
|
||||
Database:=Nil;
|
||||
Inherited;
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2002-09-07 15:15:22 peter
|
||||
Revision 1.4 2003-08-16 16:42:21 michael
|
||||
+ Fixes in TDBDataset etc. Changed MySQLDb to use database as well
|
||||
|
||||
Revision 1.3 2002/09/07 15:15:22 peter
|
||||
* old logs removed and tabs fixed
|
||||
|
||||
}
|
||||
|
10
fcl/db/db.pp
10
fcl/db/db.pp
@ -1145,7 +1145,10 @@ type
|
||||
Private
|
||||
FDatabase : TDatabase;
|
||||
Procedure SetDatabase (Value : TDatabase);
|
||||
Protected
|
||||
Procedure CheckDatabase;
|
||||
Public
|
||||
Destructor destroy; override;
|
||||
Property DataBase : TDatabase Read FDatabase Write SetDatabase;
|
||||
end;
|
||||
|
||||
@ -1161,7 +1164,7 @@ type
|
||||
FConnected : Boolean;
|
||||
FDataBaseName : String;
|
||||
FDataSets : TList;
|
||||
FDirectOry : String;
|
||||
FDirectory : String;
|
||||
FKeepConnection : Boolean;
|
||||
FLoginPrompt : Boolean;
|
||||
FOnLogin : TLoginEvent;
|
||||
@ -1459,7 +1462,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.9 2003-05-15 15:15:15 michael
|
||||
Revision 1.10 2003-08-16 16:42:21 michael
|
||||
+ Fixes in TDBDataset etc. Changed MySQLDb to use database as well
|
||||
|
||||
Revision 1.9 2003/05/15 15:15:15 michael
|
||||
+ Database class in TDBDataset is public, not published
|
||||
|
||||
Revision 1.8 2003/05/08 21:52:41 michael
|
||||
|
@ -43,9 +43,15 @@ Const
|
||||
SDatasetReadOnly = 'Dataset is read-only.';
|
||||
SNeedField = 'Field %s is required, but not supplied.';
|
||||
SNotInEditState = 'Operation not allowed, dataset "%s" is not in an edit state.';
|
||||
SErrNoDatabaseAvailable = 'Invalid operation: Not attached to database';
|
||||
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.4 2002-09-07 15:15:23 peter
|
||||
Revision 1.5 2003-08-16 16:42:21 michael
|
||||
+ Fixes in TDBDataset etc. Changed MySQLDb to use database as well
|
||||
|
||||
Revision 1.4 2002/09/07 15:15:23 peter
|
||||
* old logs removed and tabs fixed
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2003/04/01]
|
||||
# Don't edit, this file is generated by FPCMake Version 1.1 [2003/06/26]
|
||||
#
|
||||
default: all
|
||||
MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos macosx emx
|
||||
MAKEFILETARGETS=linux win32
|
||||
override PATH:=$(subst \,/,$(PATH))
|
||||
ifeq ($(findstring ;,$(PATH)),)
|
||||
inUnix=1
|
||||
@ -32,7 +32,7 @@ inOS2=1
|
||||
endif
|
||||
endif
|
||||
else
|
||||
ifneq ($(findstring cygwin,$(MACHTYPE)),)
|
||||
ifneq ($(findstring cygdrive,$(PATH)),)
|
||||
inCygWin=1
|
||||
endif
|
||||
endif
|
||||
@ -205,7 +205,7 @@ endif
|
||||
PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
|
||||
override PACKAGE_NAME=fcl
|
||||
override TARGET_UNITS+=mysqldb
|
||||
override TARGET_EXAMPLES+=testm
|
||||
override TARGET_EXAMPLES+=mtest
|
||||
override CLEAN_UNITS+=mysql mysql_com mysql_version
|
||||
override INSTALL_FPCPACKAGE=y
|
||||
override COMPILER_OPTIONS+=-S2
|
||||
@ -519,6 +519,12 @@ ifeq ($(OS_TARGET),macos)
|
||||
EXEEXT=
|
||||
FPCMADE=fpcmade.mcc
|
||||
endif
|
||||
ifeq ($(OS_TARGET),darwin)
|
||||
EXEEXT=
|
||||
HASSHAREDLIB=1
|
||||
FPCMADE=fpcmade.darwin
|
||||
ZIPSUFFIX=darwin
|
||||
endif
|
||||
else
|
||||
ifeq ($(OS_TARGET),go32v1)
|
||||
PPUEXT=.pp1
|
||||
@ -877,76 +883,40 @@ TAREXT=.tar.gz
|
||||
endif
|
||||
override REQUIRE_PACKAGES=rtl mysql
|
||||
ifeq ($(OS_TARGET),linux)
|
||||
ifeq ($(CPU_TARGET),i386)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),go32v2)
|
||||
endif
|
||||
ifeq ($(OS_TARGET),linux)
|
||||
ifeq ($(CPU_TARGET),m68k)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
endif
|
||||
ifeq ($(OS_TARGET),linux)
|
||||
ifeq ($(CPU_TARGET),powerpc)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
endif
|
||||
ifeq ($(OS_TARGET),linux)
|
||||
ifeq ($(CPU_TARGET),sparc)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
endif
|
||||
ifeq ($(OS_TARGET),linux)
|
||||
ifeq ($(CPU_TARGET),x86_64)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
endif
|
||||
ifeq ($(OS_TARGET),win32)
|
||||
ifeq ($(CPU_TARGET),i386)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),os2)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),freebsd)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),beos)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),netbsd)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),amiga)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),atari)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),sunos)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),qnx)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),netware)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),openbsd)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),wdosx)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),palmos)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),macos)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),macosx)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifeq ($(OS_TARGET),emx)
|
||||
REQUIRE_PACKAGES_RTL=1
|
||||
REQUIRE_PACKAGES_MYSQL=1
|
||||
endif
|
||||
ifdef REQUIRE_PACKAGES_RTL
|
||||
PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
|
||||
@ -1119,7 +1089,7 @@ override COMPILER:=$(FPC) $(FPCOPT)
|
||||
ifeq (,$(findstring -s ,$(COMPILER)))
|
||||
EXECPPAS=
|
||||
else
|
||||
ifeq ($(OS_SOURCE),$(OS_TARGET))
|
||||
ifeq ($(FULL_SOURCE),$(FULL_TARGET))
|
||||
EXECPPAS:=@$(PPAS)
|
||||
endif
|
||||
endif
|
||||
|
@ -7,7 +7,7 @@ main=fcl
|
||||
|
||||
[target]
|
||||
units=mysqldb
|
||||
examples=testm
|
||||
examples=mtest
|
||||
|
||||
[clean]
|
||||
units=mysql mysql_com mysql_version
|
||||
|
@ -13,6 +13,8 @@
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
{$mode objfpc}
|
||||
{$H+}
|
||||
program mtest;
|
||||
|
||||
uses db,sysutils,mysqldb;
|
||||
@ -74,6 +76,7 @@ begin
|
||||
end;
|
||||
|
||||
Var
|
||||
Dbase : TMySQLDatabase;
|
||||
Data : TMysqldataset;
|
||||
I,Count : longint;
|
||||
Bookie : TBookMarkStr;
|
||||
@ -112,77 +115,95 @@ begin
|
||||
Writeln ('Usage : mtest db user pwd sql');
|
||||
Halt(1);
|
||||
end;
|
||||
Log ('Creating Dataset');
|
||||
Data:=TMysqlDataset.Create(Nil);
|
||||
With Data do
|
||||
begin
|
||||
Log('Setting database');
|
||||
Database:=Paramstr(1);
|
||||
Log('Setting user');
|
||||
User:=Paramstr(2);
|
||||
Log('Setting password');
|
||||
PassWord := Paramstr(3);
|
||||
Log('Setting SQL');
|
||||
SQL.text := Paramstr(4);
|
||||
Log('Opening Dataset');
|
||||
Open;
|
||||
Log('Dumping fielddefs : ');
|
||||
Writeln ('Fielddefs count : ',FieldDefs.Count);
|
||||
For I:=0 to FieldDefs.Count-1 do
|
||||
DumpFieldDef(FieldDefs.Items[i]);
|
||||
Writeln ('Fields count : ',FieldCount);
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpField(Fields[i]);
|
||||
ScrollForward;
|
||||
ScrollBackWard;
|
||||
Writeln ('Going to last :');
|
||||
writeln ('---------------');
|
||||
Last;
|
||||
ScrollBackWard;
|
||||
ScrollForward;
|
||||
Writeln ('Going to first:');
|
||||
First;
|
||||
Count:=0;
|
||||
Writeln ('Browsing Forward:');
|
||||
Writeln ('------------------');
|
||||
Log ('Creating Database');
|
||||
DBase:=TMySQLDatabase.Create(Nil);
|
||||
Try
|
||||
With DBase do
|
||||
begin
|
||||
Log('Setting database');
|
||||
DatabaseName:=Paramstr(1);
|
||||
Log('Setting user');
|
||||
UserName:=Paramstr(2);
|
||||
Log('Setting password');
|
||||
PassWord := Paramstr(3);
|
||||
Log('Connecting');
|
||||
Connected:=True;
|
||||
end;
|
||||
Log ('Creating Dataset');
|
||||
Data:=TMysqlDataset.Create(Nil);
|
||||
With Data do
|
||||
While NOT EOF do
|
||||
begin
|
||||
Inc(Count);
|
||||
If Count=recordCount div 2 then
|
||||
begin
|
||||
Writeln ('Setting bookmark on record');
|
||||
Bookie:=Bookmark;
|
||||
Writeln ('Got data : "',Bookie,'"');
|
||||
end;
|
||||
Try
|
||||
Log('Setting database property');
|
||||
Database:=DBase;
|
||||
Log('Setting SQL');
|
||||
SQL.text := Paramstr(4);
|
||||
Log('Opening Dataset');
|
||||
Open;
|
||||
Log('Dumping fielddefs : ');
|
||||
Writeln ('Fielddefs count : ',FieldDefs.Count);
|
||||
For I:=0 to FieldDefs.Count-1 do
|
||||
DumpFieldDef(FieldDefs.Items[i]);
|
||||
Writeln ('Fields count : ',FieldCount);
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpField(Fields[i]);
|
||||
ScrollForward;
|
||||
ScrollBackWard;
|
||||
Writeln ('Going to last :');
|
||||
writeln ('---------------');
|
||||
Last;
|
||||
ScrollBackWard;
|
||||
ScrollForward;
|
||||
Writeln ('Going to first:');
|
||||
First;
|
||||
Count:=0;
|
||||
Writeln ('Browsing Forward:');
|
||||
Writeln ('------------------');
|
||||
With Data do
|
||||
While NOT EOF do
|
||||
begin
|
||||
Inc(Count);
|
||||
If Count=recordCount div 2 then
|
||||
begin
|
||||
Writeln ('Setting bookmark on record');
|
||||
Bookie:=Bookmark;
|
||||
Writeln ('Got data : "',Bookie,'"');
|
||||
end;
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Next;
|
||||
end;
|
||||
Writeln ('Jumping to bookmark',Bookie);
|
||||
BookMark:=Bookie;
|
||||
Writeln ('Dumping Record : ');
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Next;
|
||||
Writeln ('Dumping Next Record : ');
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Next;
|
||||
end;
|
||||
Writeln ('Jumping to bookmark',Bookie);
|
||||
BookMark:=Bookie;
|
||||
Writeln ('Dumping Record : ');
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Next;
|
||||
Writeln ('Dumping Next Record : ');
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Prior;
|
||||
Prior;
|
||||
Writeln ('Dumping Previous Record : ');
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Log('Closing Dataset');
|
||||
Close;
|
||||
Log('End.');
|
||||
Free;
|
||||
end;
|
||||
Prior;
|
||||
Prior;
|
||||
Writeln ('Dumping Previous Record : ');
|
||||
For I:=0 to FieldCount-1 do
|
||||
DumpFieldData(Fields[I]);
|
||||
Log('Closing Dataset');
|
||||
Close;
|
||||
Log('End.');
|
||||
Finally
|
||||
Free;
|
||||
end;
|
||||
Finally
|
||||
Writeln('Freeing database');
|
||||
DBase.free;
|
||||
end;
|
||||
end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.2 2002-09-07 15:15:23 peter
|
||||
Revision 1.3 2003-08-16 16:42:21 michael
|
||||
+ Fixes in TDBDataset etc. Changed MySQLDb to use database as well
|
||||
|
||||
Revision 1.2 2002/09/07 15:15:23 peter
|
||||
* old logs removed and tabs fixed
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user