PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFBDatabase
Wrapper Class for the IDatabase interface.
#include <SFBDatabase.h.hpp>
class SFBDatabase : public SFBBase;
SFMTYPEDEFWRAPPER(SFBDatabase)

Inheritance diagram

 Inheritance diagram of SFBDatabaseClass

Version

BREW 2.0 BREW 2.1 BREW 3.1 BREW 4.0
O O O O

Reference

BREW API IDatabase

Member

Public Functions
SFBDBRecordSmp CreateRecord( AEEDBField* fields , SInt32 count )
Create a new database record.
SFBDBRecordSmp GetNextRecord( Void )
Return the next record from the database.
SFBDBRecordSmp GetRecordByID( UInt16 id )
Return a pointer to the record whose record ID is specified.
UInt16 GetRecordCount( Void )
Return the number of records in the database.
Void Reset( Void )
Reset the record index of the database.
Protected Functions
static
SFBBaseSmp
FactoryByCreate( AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface.
static
SFBBaseSmp
FactoryByQuery( SFBQuerySmpConstRef query , AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface using the SFBQuery instance.

SFBDatabase::CreateRecord
Create a new database record.
[ public ]
SFBDBRecordSmp CreateRecord(
    AEEDBField* fields   // pointer to the database fields that need to be placed in a new record created by this function
    SInt32 count         // number of fields in the record
);

Exapmle

Create a new record in database.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
SFBDBRecordSmp      record;

// create the field for record setting
AChar                   str[] = {"abcdefg"};
AEEDBField              field = {AEEDB_FT_STRING, AEEDBFIELD_TEXT, STRLEN(str), str};

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// create a new record in database
record = database->CreateRecord(&field, 1);

Reference

BREW API IDATABASE_CreateRecord | AEEDBField


SFBDatabase::GetNextRecord
Return the next record from the database.
[ public ]
SFBDBRecordSmp GetNextRecord(Void);

Example

Get next record from database.

// create SFBDataMgr interface
SFBDBMgrSmp     dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp  database;
SFBDBRecordSmp  record;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get next record
record = database->GetNextRecord();

Reference

BREW API IDATABASE_GetNextRecord | SFBDatabase::Reset


SFBDatabase::GetRecordByID
Return a pointer to the record whose record ID is specified.
[ public ]
SFBDBRecordSmp GetRecordByID(
    UInt16 id   // index of record to get
);

Example

Get the specified record from database

// create SFBDataMgr interface
SFBDBMgrSmp     dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp  database;
SFBDBRecordSmp  record;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the specified record from database
record = database->GetRecordByID(3);

Reference

BREW API IDATABASE_GetRecordByID


SFBDatabase::GetRecordCount
Return the number of records in the database.
[ public ]
UInt16 GetRecordCount(Void);

Example

Get the number of records in the database.

// create SFBDataMgr interface
SFBDBMgrSmp         dbmgr = SFBDBMgr::NewInstance();
SFBDatabaseSmp      database;
UInt32              recordCount;

// open database
database = dbmgr->OpenDatabase("MyDataBase.db", true);

// get the number of records in the database
recordCount = database->GetRecordCount();

Reference

BREW API IDATABASE_GetRecordCount


SFBDatabase::Reset
Reset the record index of the database.
[ public ]
Void Reset(Void);

Reference

BREW API IDATABASE_Reset | SFBDatabase::GetNextRecord