O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—Creating the Post class

We will now create the Post class mapping to the Posts table.

We will need to redefine the table it is mapped to.

We will also need to define its relation to the User table.

package hxBlog;
#ifneko
import neko.db.Object;
import neko.db.Manager;
#end
#ifphp
import php.db.Object;
import php.db.Manager;
#end
class Post extends Object
{
public var id : Int;
public var title : String;
public var body : String;
public var postedOn : Date;
public var fk_author : Int;
public var author(dynamic, dynamic) : hxBlog.User;
static function RELATIONS()
{
return [{prop: "author", key: "fk_author", manager: User.manager}];
}
static var TABLE_NAME = "Posts";
public static var manager = new Manager<Post>(Post);
}

What just happened? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required