Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

db_t Class Reference

#import <db_t.h>

Inheritance diagram for db_t:

Object List of all members.

Public Member Functions

(id) init
(int) init_2nd_stage
(id) free
(int) save_record_to_db::
(int) fetch_record_from_db::
(int) delete_record_in_db::
(int) delete_subrecords_in_db::
(void) find_largest_keys_for_record::
(void) unlock_record_in_db:
(maybe_tlock_record_in_db:
(char *) is_record_locked:
(long) new_recid::
(maybe_tfind_keys_for_record::
(int) do_exec:
(void) freeres
(void) update_kort_ui:
(pointerlist_t *) list_of_instances:::
(int) find_last_saved_field:
(maybe_tfind_allowed_value:::::

Static Public Member Functions

(id) init_with_values:

Protected Attributes

appbus_tbus
MYSQL mysli
char * sql_statement
MYSQL_RES * resultset_of_query
MYSQL_ROW exactly_one_row
my_ulonglong how_many_rows
char lock_info_string [200]
char lock_info_string_of_locked_record [200]

Detailed Description

here is class for db access.


Member Function Documentation

- (int) delete_record_in_db: (id< valuepair_p > *)  values
: (id< record_status_p >)  recstat
 
 

removes record from db

Parameters:
values is pointer to values of the record about to be deleted. and most likely this method does not even use this parameter for any purpose.
recstat is record status structure
Returns:
0 in success, something else otherwise

- (int) delete_subrecords_in_db: (record_t *)  aRecord
: (long)  record_id_master
 
 

removes sub-records from db

Parameters:
aRecord is pointer to record_t
record_id_master is value of record_id_master surrogate of the records in db table that are in need of deletion.
Returns:
0 in success, something else otherwise

- (int) do_exec: (expected_query_result_t aExpectedResult  
 

method for executing a query, takes input from instance variable sql_statement. this is the workhorse that does all select/update/delete/etc.

Parameters:
aExpectedResult tells do_exec how many rows we expect in return. If this method is told that one line is expected, then this method will also fetch the one row if the query turns out to be a successful one.
Returns:
error code, 0 on success

- (int) fetch_record_from_db: (id< valuepair_p > *)  values
: (id< record_status_p >)  recstat
 
 

gets record to db

Parameters:
values is list values for database record
recstat is record status structure
Returns:
0 in success, something else otherwise

- (maybe_t) find_allowed_value: (id< record_status_p >)  aRecStat
: (id< valuepair_p >)  aValue
: (wchar_t *)  aCurrentValue
: (char *)  aAllowedValuesTable
: (char *)  aAllowedValuesColumn
 
 

method for finding out if current value is among allowed ones and if not, helping user in choosing one. note that user has no other possibility but to choose one :-)

Parameters:
aRecStat is status of the record where aValue belongs to
aValue is the value (form field) whose value we're seeking
aCurrentValue is the value as wchar_t directly from field
aAllowedValuesTable is db table where list of allowed values is found
aAllowedValuesColumn is db column where list of allowed values is found
Returns:
returns yes when a full screen update is in order

- (maybe_t) find_keys_for_record: (id< valuepair_p > *)  values
: (id< record_status_p >)  recstat
 
 

method that finds keys for a record. may require user interaction.

Parameters:
values is list of values in current record
recstat is the record status interface
Returns:
yes on success

- (void) find_largest_keys_for_record: (id< valuepair_p > *)  values
: (id< record_status_p >)  recstat
 
 

invents surrogate keys for a record not yet fetched

Parameters:
values is list values for database record
recstat is record status structure
Returns:
none

- (int) find_last_saved_field: (id< valuepair_p > *)  values  
 

method that finds index of last field from form that is saved to db.

Parameters:
values is the set of values from form
Returns:
index or last saved value or -1 if there is none

- (id) free  
 

frees allocated memory

- (void) freeres  
 

method for releasing in safe manner memory allocated by query results

- (id) init  
 

default initializer

- (int) init_2nd_stage  
 

this method asks for password and creates db connection

+ (id) init_with_values: (appbus_t *)  aBus  
 

the "allocator" usually used is here

- (char *) is_record_locked: (id< record_status_p >)  recstat  
 

queries for lockedness of a record

Parameters:
recstat is record status structure
Returns:
lock string if record is locked, NULL if not

- (pointerlist_t *) list_of_instances: (char *)  recname
: (long)  recid
: (long)  recid_master
 
 

method that returns list of network addresses of other instances of this program. format of the list may depend on underlying network protocol, in UDP case it might be something like host:port

Parameters:
recname if non-NULL only ui:s registered to this record name will be included to list
recid if non- -01 only ui:s registered to this recid will be included in the list. This is evaluated only if recname is non-NULL.
recid_master same meaning as with recid but for recid_master.
Returns:
pointerlist_t that the caller will own and hopefully delete. in case of error nil may be returned

- (maybe_t) lock_record_in_db: (id< record_status_p >)  recstat  
 

locks a record in db from others to use

Parameters:
recstat is record status structure
Returns:
yes if locking did succeed.

- (long) new_recid: (id< valuepair_p > *)  values
: (id< record_status_p >)  recstat
 
 

returns unique long for tab/col pair

Parameters:
values is list values for database record
recstat is record status structure
Returns:
none

- (int) save_record_to_db: (id< valuepair_p > *)  values
: (id< record_status_p >)  recstat
 
 

saves record to db

Parameters:
values is list values for database record
recstat is record status structure
Returns:
0 in success, something else otherwise

- (void) unlock_record_in_db: (id< record_status_p >)  recstat  
 

unlocks a record in db for others to use

Parameters:
recstat is record status structure
Returns:
none

- (void) update_kort_ui: (id< record_status_p >)  aRecStat  
 

method for maintaining kort_ui table


Member Data Documentation

- (appbus_t*) bus [protected]
 

application bus pointer

- (MYSQL_ROW) exactly_one_row [protected]
 

one row from resultset of last query

- (my_ulonglong) how_many_rows [protected]
 

size of resultset of last query

- (char lock_info_string[200]) [protected]
 

our id string saved to kort_ui table

- (char lock_info_string_of_locked_record[200]) [protected]
 

our id string saved to some data table

- (MYSQL) mysli [protected]
 

actual database handle

- (MYSQL_RES*) resultset_of_query [protected]
 

resultset of last query

- (char*) sql_statement [protected]
 

pointer to sql statement text about to be executed


The documentation for this class was generated from the following file:
Generated on Sun May 15 23:45:24 2005 for kort4 by  doxygen 1.4.2