#include <SLPluginFeature.hpp>
Inheritance diagram for SLPluginFeature::DBAccess:
Public Member Functions | |
virtual SLPluginFeature::DBAccess::Connection & | getConnection (const char *dbName="segusoland")=0 |
example of usage :
#include <iostream> #include "segusoland.hpp" #include "SLPluginRegister.hpp" #include "SLPluginFeature.hpp" try { // get DB Feature (quick) SLPluginFeature::DBAccess *db = SL_FEATURE_GET(DBAccess); // real connection to the database (speed may vary) SLPluginFeature::DBAccess::Connection &con = db->getConnection(NULL); // get the results of a SQL request SLPluginFeature::DBAccess::Results *results = con.execSQL("select * from files limit 10"); // go through the results // database columns values are all in "char *" format while (results->next()) { for (unsigned int i = 0; i < results->getRowCount(); i++) { const char *str = results->getColumn(i); // print the column content std::cout << "| " << ((str == NULL) ? "NULL" : str); } std::cout << std::endl; } // mandatory : free results set con.freeResults(results); // dispose DB Feature (quick) SL_FEATURE_DISPOSE(db); } catch (SLPluginFeature::DBAccess::Exception &e) { SL_WARNING("GOT AN EXCEPTION : " << e.getMessage().to_utf8()); } catch (SLPluginRegister::NotFoundException &e) { SL_WARNING("COULD NOT FIND THE DBAccess FEATURE : " << e.getMessage().to_utf8()); }
|
Returns an open connection on the database. The connection is taken from a pool and is already connected to the database.
|