1 |
|
#include <stdio.h> |
2 |
|
#include <stdlib.h> |
3 |
|
|
4 |
|
#include "dbObject.h" |
5 |
|
|
6 |
|
#define DBSTORE_WANT_DETAILS |
7 |
|
#include "userTable.h" |
8 |
|
#include "groupTable.h" |
9 |
|
#undef DBSTORE_WANT_DETAILS |
10 |
|
|
11 |
|
int |
12 |
|
main() |
13 |
|
{ |
14 |
|
dbUser *user = NULL; |
15 |
|
|
16 |
|
/* Create Object */ |
17 |
|
user = (dbUser*)db_newObject( &dbUserDef ); |
18 |
|
if( user == NULL ) { |
19 |
|
printf( "Cannot create new user object\n" ); |
20 |
|
printf( "Error Code %d [%s]\n", dgdberrno, dgdberrstr ); |
21 |
|
exit(1); |
22 |
|
} |
23 |
|
|
24 |
|
setProperty( user, "userName", "chris@nfluid.com" ); |
25 |
|
printf( "Set: %s\n", user->key.userName ); |
26 |
|
|
27 |
|
/* Load Object */ |
28 |
|
if( loadObject( user ) < 0 ) { |
29 |
|
switch( dgdberrno ) { |
30 |
|
case DBE_NOTFOUND: |
31 |
|
printf( "Record not found\n" ); break; |
32 |
|
default: |
33 |
|
printf( "Error Code %d [%s]\n", dgdberrno, dgdberrstr ); break; |
34 |
|
|
35 |
|
} |
36 |
|
} |
37 |
|
printf( "Loaded: %s - %s\n", user->data.email, user->data.realName ); |
38 |
|
|
39 |
|
/* Change a property so that object becomes dirty, then save... */ |
40 |
|
setProperty( user, "realName", "The Evil Chris Smith" ); |
41 |
|
saveObject( user ); |
42 |
|
|
43 |
|
/* Destroy Object */ |
44 |
|
destroyObject( user ); |
45 |
|
|
46 |
|
return 0; |
47 |
|
} |
48 |
|
|
49 |
|
/* ------------------------------------------------------------------------- */ |
50 |
|
/* end */ |