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 ...
Get haXe 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.