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

Time for action—Listing users

Now, we are going to create a function to list all users.

This one is even simpler than listing posts because it has no relations.

public static function listUsers()
{
Lib.print("Users:<br/>");
for(u in hxBlog.User.manager.all(false))
{
Lib.print(u.username+"<br/>");
}
}

Our class now looks like the following:

#ifneko import neko.db.Connection; import neko.db.Mysql; import neko.db.Manager; import neko.Web; import neko.Lib; #end #ifphp import php.db.Connection; import php.db.Mysql; import php.db.Manager; import php.Web; import php.Lib; #end class HxBlog { public static function main(): Void { var connection : Connection; var options = { user : "root", pass : "root", socket : null, host : "127.0.0.1", port : 8889, database ...

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