WYRDTEK Home Features Reference Downloads About



int es_mbb_mbn_r( struct es_mbb *fb, const char *fieldname, struct es_mbn ***pvar );


struct es_mbb Field-binding collection.
const char *fieldname Database field name.
struct es_mbn ***pvar Reference to database node pointer program variable.

Return Codes

ES_ERROR_NONE Success. No errors.
ES_ERROR_INVALIDFIELDTYPE Database field is not a child node or node-reference field (ES_FLDTYPE_MBN).
ES_ERROR_UNKNOWNFIELD Unknown database field in this class.


Bind by reference the database node program variable referenced by pvar with the database field fieldname. The field-binding fb must have been previously constructed via es_mbb_new().

Binding by reference means that a pointer to fieldname's value is copied to the program variable referenced by pvar during both fetch and update operations. The contents of fieldname may then be read or assigned to directly by de-referencing *pvar.

This is particularly useful for constructing new database nodes via es_mbn_new(), since a reference to fieldname's location (i.e. *pvar) can be passed directly as parameter to es_mbn_new(). It also simplifies detecting whether a child node field has been initialized, since the contents of database nodes are always zero initialized.

/* given that we've constructed a database, class, binding, iterator and node */
struct es_mb *database;
struct es_mbc *c_parent;
struct es_mbb *b_parent;
struct es_mbi *i_parent;
struct es_mbn *n_parent;

/* construct field-binding for "Child" and bind a struct es_mbn* by reference */
struct es_mbn **f_child;
es_mbb_mbn_r( b_parent, "Child", &f_child );

/* lookup some row in the parent node */
es_mbi_findupdate( i_parent, n_parent );

/* construct a new child node if does not exist */
if ( ! *f_child ) {
  es_mbn_new( c_child, f_child );

[Back To Reference] [Back To Reference/es_mbb]