http://sourceforge.net/projects/oordb/?source=directory
Description
OORDB is a Harbour Library that provides capability to define, build and maintain Relational Databases using an Object Oriented approach in which the Database is maintained by defining Primary Keys, Relations, Dependencies, Constrains (at table and field level), Secondary Indexes are supported.
Fields can be of the following types:
String, Memo, Integer, Float, Logical, Date, DateTime, Modtime, Object ( a Table Object )
/*
* $Id: buildTable.prg 14 2012-03-05 02:54:51Z tfonrouge $
*/
#include "oordb.ch"
CLASS MyDatabase FROM TDataBase
PROPERTY Directory VALUE "data"
ENDCLASS
CLASS MyTable FROM TTable
METHOD InitDataBase INLINE MyDatabase():New()
DEFINE FIELDS
PROPERTY AutoCreate VALUE .T.
PROPERTY TableFileName VALUE "mytable"
ENDCLASS
BEGIN FIELDS CLASS MyTable
ADD STRING FIELD "Name" SIZE 40
ADD STRING FIELD "LastName" SIZE 40
ADD DATE FIELD "Birth"
ADD STRING FIELD "Gender" SIZE 1 ;
VALIDVALUES {"M"=>"Male","F"=>"Female"} ;
DEFAULT "M"
END FIELDS CLASS
PROCEDURE Main()
LOCAL table
LOCAL o
table := MyTable():New()
o := table:DisplayFields()
IF table:Eof()
Poblate( table )
ENDIF
? "Table '" + table:ClassName + "' with " + NTrim( table:Count ) + " records."
?
table:DbGoTop()
WHILE !table:Eof()
? o:Name, o:LastName, o:Birth, o:Gender
table:DbSkip()
ENDDO
RETURN
STATIC PROCEDURE Poblate( table )
LOCAL h
LOCAL itm
h := { ;
{ "Name" => "Homer", "LastName" => "Simpson", "Birth" => Date() - ( 365 * 40 ) },;
{ "Name" => "Marge", "LastName" => "Bouvier", "Birth" => Date() - ( 365 * 33 ), "Gender" => "F" }, ;
{ "Name" => "Bart", "LastName" => "Simpson", "Birth" => Date() - ( 365 * 10 ) } , ;
{ "Name" => "Lisa", "LastName" => "Simpson", "Birth" => Date() - ( 365 * 8 ), "Gender" => "F" }, ;
{ "Name" => "Maggie", "LastName" => "Simpson", "Birth" => Date() - ( 365 * 2 ), "Gender" => "F" } ;
}
FOR EACH itm IN h
table:InsertRecord( itm )
NEXT
RETURN
/*
* $Id:$
*/
#include "oordb.ch"
PROCEDURE Main()
LOCAL person
LOCAL employee
person := TPerson():New()
AddPerson( person )
? person:RecCount()
employee := TEmployee():New()
? employee:Field_Type:Value
? employee:RecCount()
WAIT
RETURN
STATIC PROCEDURE AddPerson( person )
IF person:Insert()
person:Field_FirstName:Value := "Homer"
person:Field_LastName:Value := "Simpson"
person:Field_Birth:Value := Date()-(35*365)
person:Post()
ENDIF
RETURN
Saudações,
Itamar M. Lins Jr.