A concrete example of SPOD use

Let's see a concrete example of how to use that.

Set up a database in your MySQL server with a table named Users.

In this table, add the following three fields:

  1. id: This should be the Primary Key and have auto_increment, so that we don't have to worry about generating the Primary Keys.
  2. username: This should be a text; we will use it to store the user's username.
  3. password: This should be a text too; we will use it to store the user's password hash.

Setting the object

Now, let's create a User class reflecting those fields and useable as SPOD:

class User extends neko.db.Object
{
   public var id : Int;
   public var username : String;
   public var password : String;

   public static var manager = new neko.db.Manager<User>(User);
}

Note ...

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.