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(); } }
What just happened?
This...