Function createModel

Synopsis

#include <include/Database.h>

void createModel()

Description

No description yet.

Mentioned in

Source

Lines 65-88 in src/Database.cpp. Line 68 in include/Database.h.

void Database::createModel()
{
    if(!mx)
        throw std::logic_error("register bean classes first");
    Model mdl=mx->getModel();
    for(Model::iterator it=mdl.begin();it!=mdl.end();it++){
        Table& t=it->second;
        std::string query="CREATE TABLE "+t.name+" (";
        bool needComma=false;
        for(std::map<std::string,Column>::iterator c=t.columns.begin();c!=t.columns.end();c++){
            if(needComma)
                query+=", ";
            needComma=true;
            Column& col=c->second;
            query += col.name + " ";
            if(col.name==HIBERLITE_PRIMARY_KEY_COLUMN)
                query+="INTEGER PRIMARY KEY AUTOINCREMENT";
            else
                query+=col.storage_type;
        }
        query +=");";
        dbExecQuery(query);
    }
}





Add Discussion as Guest

Log in