Take a look at how this is done. First, you need to create a secondary table to link to, and alter the first
table to include a field that will contain the second table ??™ s unique identifier:
class CreateTableChapters
{
public static function main()
{
var dbLoc : String = ???Wrox.db3???;
var dbFactory = create( dbLoc );
}
public static function create( loc : String )
{
var cnx = neko.db.Sqlite.open( loc );
cnx.request( ???CREATE TABLE Chapter (
(continued)
296
Part II: Server Side, JavaScript, and Flash: Oh My!
int_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
int_chapter INTEGER NOT NULL,
var_title TEXT NOT NULL )??? );
cnx.request( ???ALTER TABLE Author ADD int_chapter_id INTEGER??? );
cnx.close();
}
}
Now that the tables are sorted, they need to be mapped. The class for the Author table already exists; it
just needs to be modified to include the relationship data:
import Chapter;
class Author extends neko.db.Object
{
public var int_id : Int;
public var var_username : String;
public var var_password : String;
public var var_email : String;
public var int_chapter_id : Int;
public var dte_added : Date;
static function RELATIONS()
{
return [{ prop : ???chapter???, key : ???int_chapter_id???, manager :
untyped Chapter.
Pages:
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582