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:
id
: This should be the Primary Key and haveauto_increment
, so that we don't have to worry about generating the Primary Keys.username
: This should be a text; we will use it to store the user's username.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
Note: We are going to use the standard Manager
.
Remember how we named our table Users
and see how our class is named User
? This makes perfect sense and it respects/accounts for what people are used to seeing. Still, we will need...