Code: Alles auswählen
qDebug() << categories;
foreach ( int id, categories.keys() )
{
qDebug() << id;
QSqlQuery apps ( db );
apps.prepare ( "SELECT id, category, name FROM \":table\" WHERE category = \":category\" ORDER BY name;" );
apps.bindValue ( ":table", m_tableName );
apps.bindValue ( ":category", id );
apps.exec();
if ( apps.lastError().isValid() )
{
qDebug() << apps.executedQuery() << "\n" << apps.lastError() << "\n" << apps.boundValues();
}
while ( apps.next() )
{
qDebug() << apps.value ( 0 ) << "\t" << apps.value ( 1 ) << "\t" << apps.value ( 2 );
}
}Code: Alles auswählen
QMap((1, "Mathe/Physik")(2, "Informatik"))
1
"SELECT id, category, name FROM "?" WHERE category = "?" ORDER BY name;"
QSqlError(-1, "Parameter count mismatch", "")
QMap((":category", QVariant(int, 1) ) ( ":table" , QVariant(QString, "programs") ) )
2
"SELECT id, category, name FROM "?" WHERE category = "?" ORDER BY name;"
QSqlError(-1, "Parameter count mismatch", "")
QMap((":category", QVariant(int, 2) ) ( ":table" , QVariant(QString, "programs") ) )