Prev | Current Page 542 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

However, as new wrappers materialize, it is recommended
that you check their level of transaction support.
As with all the haXe database features, using database transactions in haXe is dead simple. Let ??™ s jump
straight in and take a look at an example:
class Transaction
{
public static function main()
{
var dbLoc = ???Wrox.db3???;
var dbPop = transact( dbLoc );
}
public static function transact( loc : String )
{
// open the database
var cnx = neko.db.Sqlite.open( loc );
// begin the transaction
cnx.startTransaction();
// construct the sql string
var sql = ???INSERT INTO Author ???;
sql += ??? ( var_username, var_password, var_email, dte_added ) VALUES ( ???;
sql += ?????™Nicolas??™, ???mtw1n??™, ???ncannasse@motion-twin.com??™, ??????;
sql += Date.now().toString() + ?????™ )???;
// execute the sql
cnx.request( sql );
// construct the second sql string - should return 0 records
sql = ???SELECT COUNT(*) FROM Author WHERE var_username=??™MetalMickey??™???;
// execute second sql
var rec = cnx.


Pages:
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554