Prev | Current Page 559 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

When updating or inserting values into a database table using one of these objects, the
Manager class loops through these variables and attempts to insert the contained data into fields of the
same name. Now, chances are, you ??™ re going to want to add other variables to your objects that do not
map to database fields. If so, then you need to list those variable names in a static string array called
PRIVATE_FIELDS , so that the Manager object knows not to include these values. For instance, given
your current Author table, you may have an object used for mapping that also provides a couple of
arrays used for other purposes. In this case, you need to make sure they are listed in a static PRIVATE_
FIELDS variable:
class Author extends neko.db.Object
{
// field reference variables
public var int_id : Int;
public var var_username : String;
public var var_password : String;
public var var_email : String;
public var dte_added : Date;
// custom variables
public var chaptersWritten : Array < String > ;
private var copiesSold : Int;
// associated table name
static var TABLE_NAME = ???Author???;
// associated table id field
static var TABLE_IDS = [???int_id???];
// list our non-field variables
static var PRIVATE_FIELDS = [???chaptersWritten???, ???copiesSold???];
// manager for this class
public static var manager = new neko.


Pages:
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571