Hey,

Ive come to the point where I need to make a db handler class for our project. 
I have a few things I need to be able to do, and that is either creating a new 
job (which is only a new id number for a job, the table could be the same, or a 
new table could be made), then I wish to be able to modify my db data. What I 
was looking for was some way of initiating a database connection in one method, 
and then I want to be able to send that connection/session to my methods. Is 
this possible, or would I have to initiate a connection for each task I want to 
do, and then close it again after committing my data? I will log gps data, so 
Id like to make a connection, then repeat my «submit gps data» every time I get 
a new valid string.

The way I see it in the tutorial, I see only a connection being set up within 
the method before doing all tasks the example calls for. Im not sure if this 
makes sense, and I would go at it trying different angles a whole lot longer, 
but we are running out of time here, so Im hoping to be able to get some help 
here. Basically this is how Id wish to be able to do it:

Session dbSession(){
        Wt::Dbo::backend::MySQL mysql("db", "root",  «pass", "127.0.0.1", 3306);
    mysql.setProperty("show-queries", "true");
    Wt::Dbo::Session session;
    session.setConnection(mysql);

    return session;

}

I was also thinking/trying:

class dbSession{

        Wt::Dbo::backend::MySQL mysql(«db", "root", «pass", "127.0.0.1", 3306);
    mysql.setProperty("show-queries", "true");
    Wt::Dbo::Session session;
    session.setConnection(mysql);

}


then from within a different method:

      session = dbSession;

      session.mapClass<Config>("config");
      session.mapClass<nmea_GSA>("nmea_GSA");
      session.mapClass<User>("user");

and something like:

void enterGpsData(dbSession){

//set the different variables and enter the dbo fields.
}


This became a bit messy, but I think you know what I mean and will be able to 
point me in the right direction if you have done what I am wanting to do here.

Regards,
Tor



Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to