Database

HaQuery does not depend on any database library. Below I show you using orm library with HaQuery.

Example of using orm database library

After installing library, you must specify connection string. Good place for that is a global config file (src/config.xml):

<config>
    <custom name="databaseConnectionString" value="mysql://user:pass@host/dbname" />
</config> 

Use preInit method in your base page (which super for all your pages) to make connection:

package pages.base;

class Server extends BaseServer
{
    public var db(default, null) : Db;
    public var orm(default, null) : Orm;
    
    function preInit()
    {
        db = new Db(config.customs.get("databaseConnectionString"));
        orm = new Orm(db);
    }
} 

Run next command to generate database table-related classes:

haxelib run HaQuery orm 

The above command assume, what you have database connection string in your src/config.xml file. If not, specify that string after "orm".

version #226, modified 2014-12-08 20:48:31 by yar3333