sorry, wrong question...
i need this
something_as_assoc_array_inPHP DB:myDbFunction(){
//set db's credentials
if (!db->open()) {
// show some error message and stuff like that
qstr
= QString("your query goes here; ");
query.exec(qstr);
if (!query.first()) {
// in this case no data has been selected
// do what you think you shoul
}
do {
something_as_assoc_array_inPHP = query..........
} while (query.next())
delete db;
return something_as_assoc_array_inPHP;
}
code:
var = DB:myDbFunction();
qtDebug() << var[0]["id"];
something_as_assoc_array_inPHP DB:myDbFunction(){
QSqlDatabase *db = QSqlDatabase::addDatabase("QPSQL7", "mainConnect");
//set db's credentials
if (!db->open()) {
// show some error message and stuff like that
QSqlQuery query(db);
QString qstr;
qstr = QString("your query goes here; ");
query.exec(qstr);
if (!query.first()) {
// in this case no data has been selected
// do what you think you shoul
}
do {
something_as_assoc_array_inPHP = query..........
} while (query.next())
delete db;
return something_as_assoc_array_inPHP;
}
code:
var = DB:myDbFunction();
qtDebug() << var[0]["id"];
To copy to clipboard, switch view to plain text mode
Bookmarks