[Valentina] M:M problems
Eric Forget
forgete at cafederic.com
Sun Jan 19 21:47:15 CST 2003
Hi,
I'm pretty new to both Valentina and SQL, so forgive me if it is a pretty
obvious thing. I'm doing a Jaguar Address Book like application. So my
minimal classes are like this:
class CGroup : public VDK_BaseObject
{
public:
VDK_String mName;
public:
CGroup( void )
: VDK_BaseObject( "Book" ),
mName( "Name", 512 ) {}
};
class CPerson : public VDK_BaseObject
{
public:
VDK_String mName;
public:
CPerson ( void )
: VDK_BaseObject( "Receipe" ),
mName( "Name", 512 ) {}
};
class CGroupPerson : public VDK_BaseObject
{
public:
VDK_ObjectPtr mGroupPtr;
VDK_ObjectPtr mPersonPtr;
public:
CGroupPerson ()
: VDK_BaseObject( "GroupPerson" ),
mGroup( "Group", NULL, kFBL_CASCADE ),
mPerson( "Person", NULL, kFBL_CASCADE ) {}
};
class CDatabase : public VDK_DataBase
{
public:
CGroup mGroup;
CPerson mPerson;
CGroupPerson mGroupPerson;
public:
ICDatabase() {}
}
And now I'm trying to add a person to a group:
void
CDatabase::AddPersonToGroup(UInt32 personIndex, UInt32 groupIndex)
{
if (GotoPerson(personIndex) and GotoGroup(groupIndex)) {
char query[] = "SELECT * FROM GroupPerson WHERE Group.RecID =
GroupPtr and Person.RecID = PersonPtr";
VDK_Cursor cursor(this);
int count;
cursor.ExecuteSQL(query);
count = cursor.GetRecordCount();
if (count == 0) {
// Add a new record in the mGroupPerson table...
}
}
}
The count variable always return 0.
Also, how do you get an FBL_ArraySet with all the person of a certain group?
Thanks,
Éric
___________________________________________________________________
Eric Forget Cafederic
ForgetE at cafederic.com <http://www.cafederic.com/>
Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
More information about the Valentina
mailing list