Prev | Current Page 538 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

quote( user.user ) + ???, ???;
sql += cnx.quote( user.pass ) + ???, ???;
sql += cnx.quote( user.email ) + ???, ???;
sql += cnx.quote( user.added ) + ??? )???;
// execute the sql
cnx.request( sql );
}
// close the database connection
cnx.close();
}
}
As you can see, much of the bulk of this class is taken up by the array containing the data required to
populate the database and the loop that constructs the SQL string. The rest of the class is pretty much
identical to that of CreateDB .
You can generally use the same connection class functionality when updating and deleting records from
the database. For example, to update a record, you could do the following:
class UpdateDB
{
public static function main()
{
var dbLoc = ???Wrox.db3???;
var dbPop = update( dbLoc );
}
public static function update( loc : String )
{
// open the database
var cnx = neko.db.Sqlite.open( loc );
// construct the sql string
var sql = ???UPDATE Author SET ???;
sql += ???var_password = ??? + cnx.quote( ???h4X3ruL35??? );
sql += ??? WHERE var_username = ??? + cnx.


Pages:
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550