Prev | Current Page 539 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

quote( ???Lee??? );
// execute the sql
cnx.request( sql );
// close the database connection
cnx.close();
}
}
While deleting a record might look like this:
class DeleteDB
{
public static function main()
(continued)
281
Chapter 11: Performing Server-Side Trickery
{
var dbLoc = ???Wrox.db3???;
var dbPop = deleteRec( dbLoc );
}
public static function deleteRec( loc : String )
{
// open the database
var cnx = neko.db.Sqlite.open( loc );
// construct the sql string
var sql = ???DELETE FROM Author ???;
sql += ??? WHERE var_username = ??? + cnx.quote( ???Lee??? );
// execute the sql
cnx.request( sql );
// close the database connection
cnx.close();
}
}
As you can see from these examples, when passing in data from variables to construct the SQL strings
ready for consumption by the request method, the variable data is first passed to the Connection
.quote method. This is because, as honorable as your application users are, you do not want to rely on
your users formatting the text for acceptance by the database.


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