Prev | Current Page 548 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

This way, you can choose to iterate through each
column while the column index is less than the value of the nfields property, thus guaranteeing access
to all of the contained data.
Iterating Through a ResultSet
The ResultSet provides the necessary methods as detailed by the typedef Iterator . This means that a
populated ResultSet object can be iterated in a loop allowing easy access to its content. This is an
invaluable feature when dealing with ResultSet s containing more than one record:
class DBIteration
{
public static function main()
{
var dbLoc = ???Wrox.db3???;
iter( dbLoc );
}
public static function iter( loc : String )
{
// open the connection
var cnx = neko.db.Sqlite.open( loc );
var sql = ???SELECT * FROM Author???;
// execute the query
var rec = cnx.request( sql );
// loop through the rows and print user data
for ( user in rec )
neko.Lib.print( user.var_username + ???\t??? + user.var_password + ???\n??? );
// close the connection
cnx.close();
}
}
As you can see, looping through each record in the ResultSet proves to be a very easy task indeed.


Pages:
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560