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

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); ...

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