Prev | Current Page 553 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

db.Sqlite.open( loc );
// initialize the neko.db.Manager class
neko.db.Manager.cnx = conn;
neko.db.Manager.initialize();
// get the author with the id value 1
var u = Author.manager.get(1);
if( u == null ) {
u = new Author();
// set the id to 1
u.int_id = 1;
// populate remaining items
u.var_username = ???Neko???;
u.var_password = ???beeswax???;
(continued)
288
Part II: Server Side, JavaScript, and Flash: Oh My!
u.var_email = ???Neko@TheCat.co.jp???;
u.dte_added = Date.now();
u.insert();
} else {
// update
u.dte_added = Date.now();
u.update();
}
neko.Lib.print( ???name: ??? + u.var_username + ???, pass: ??? +
u.var_password + ???\n??? );
// close the connection
neko.db.Manager.cleanup();
conn.close();
}
}
The Author class is the class that defines the data contained in the Author table of the example SQLite
database. The five field reference variables represent each of the columns in the table using the same
name. This is important for the Manager class to be able to map the columns successfully.


Pages:
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565