Time for action – Creating our SPOD class

First, let's create a very simple SPOD class representing our blog posts.

Add this code to Post.hx:

class Post extends neko.db.Object
{
   public var id : Int;
   public var title : String;
   public var body : String;
   
   public static var manager = new neko.db.Manager<Post>(Post);
}

You also have to create the corresponding table in your SQL database. You can create it and name it "myBlog".

In order to do so, you can use the following SQL statement:

CREATE TABLE  'Post' (
'id' INT NOT NULL AUTO_INCREMENT,
'title' TEXT NOT NULL,
'body' LONGTEXT NOT NULL,
PRIMARY KEY (  'id' )
) ENGINE = MYISAM;

Once you have done this, our SQL database is set up correctly and we have objects to work with. You may want to populate it with ...

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.