Prev | Current Page 566 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

db3???;
getAuthor( dbloc );
}
public static function getAuthor( loc : String )
{
var conn = neko.db.Sqlite.open( loc );
neko.db.Manager.cnx = conn;
neko.db.Manager.initialize();
// get the author with the id value 1
var users = Author.manager.all( true );
for ( u in users ) {
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???;
u.var_email = ???Neko@TheCat.co.jp???;
(continued)
294
Part II: Server Side, JavaScript, and Flash: Oh My!
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();
}
}
As you can see, little was required to facilitate this change, and yet suddenly, you have access to the
entire contents of the table as a list of objects. With minimal effort, you could extract whatever data you
saw fit while still adhering to an object mapping system.


Pages:
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578