Book Image

haXe 2 Beginner's Guide

5 (1)
Book Image

haXe 2 Beginner's Guide

5 (1)

Overview of this book

Table of Contents (21 chapters)
haxe 2
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – Reading the template from resources


To read our template from resource and store it, we will simply add these lines of code:

var templateCode : String;
templateCode = haxe.Resource.getString("template");

So, we now have the following:

import Post;

class Main
{   
   public static function main()
   {
      //Parameters to connect to the MySQL database
      var cnx = neko.db.Mysql.connect({ 
            host : "localhost",
            port : 3306,
            database : "myBlog",
            user : "root",
            pass : "",
        });
      
      //Initialize the SPOD system
        neko.db.Manager.cnx = cnx;
        neko.db.Manager.initialize();

      var posts = Post.manager.all();

      var templateCode : String;
      templateCode = haxe.Resource.getString("template");

      //We've done our processing, let's clean things and disconnect
        neko.db.Manager.cleanup();
       
 cnx.close();
   }
}