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—Creating the connection to the database

For our main function, we are going to do it systematically.

At first, let's create the connection to the database:

#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 : "hxBlog" }; connection = Mysql.connect(options); //Tell manager to use this connection. Manager.cnx = connection; Manager.initialize(); //Do things connection.close(); ...

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