本文整理汇总了C++中QSqlQuery::first方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlQuery::first方法的具体用法?C++ QSqlQuery::first怎么用?C++ QSqlQuery::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlQuery
的用法示例。
在下文中一共展示了QSqlQuery::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLocationID
bool DateModel::getLocationID(int& ID)
{
QSqlQuery query;
query.prepare(
tr("SELECT TOP (1) id_location")+
tr(" FROM dbo.GL_Session")+
tr(" ORDER BY ID DESC")
);
if (!query.exec()) return false;
if (query.numRowsAffected()!=1) return false;//It must *always* find an id
query.first();
ID=query.value(0).toInt();
return true;
}
示例2: countReadableUsers
int DataBase::countReadableUsers(QString userID)
{
int result;
connect();
QString queryString = "SELECT count() FROM readableUsers WHERE userID="+userID;
QSqlQuery countReadableUsersQuery;
countReadableUsersQuery.prepare(queryString);
countReadableUsersQuery.exec();
countReadableUsersQuery.first();
if (countReadableUsersQuery.value(0).toString() =="")
result = 0;
else
result = countReadableUsersQuery.value(0).toInt();
disconnect();
return result;
}
示例3: on_pushButtonMedecinAjouter_clicked
void MainWindow::on_pushButtonMedecinAjouter_clicked()
{
//renvoi le medNum maximum pour pouvoir faire un +1
QSqlQuery req;
req.exec("select max(docNum)+1 from medecin;");
req.first();
this->base.exec("insert into medecin values ("+req.value(0).toString()+
",'"+ui->lineEditMedecinNom->text().trimmed()+
"','"+ui->lineEditMedecinNumSS->text().trimmed()+
"','"+ui->lineEditMedecinAdr1->text().trimmed()+
"','"+ui->lineEditMedecinAdr2->text().trimmed()+
"','"+ui->lineEditMedecinCP->text().trimmed()+
"','"+ui->lineEditMedecinVille->text().trimmed()+
"','"+ui->lineEditMedecinTel->text().trimmed()+"')");
this->chargeListeMedecin();
}
示例4: GetFeedById
void Feeds::GetFeedById(Feed * feed)
{
QSqlQuery query;
QString prepQuery = "SELECT * FROM FEEDS WHERE id = :id ";
query.prepare(prepQuery);
query.bindValue(":id", feed->id);
if(!query.exec())
{
return;
}
query.first();
feed->title = query.value(2).toString();
feed->link = query.value(1).toString();
feed->is_on = query.value(3).toBool();
}
示例5: doDelete
void xtClassCode::doDelete()
{
QString sql = "SELECT deleteClassCode(%1) AS result;";
sql = sql.arg(getId());
if(xtlib::debug)
qDebug() << "executing: " << sql;
QSqlQuery query;
query.exec(sql);
if(query.first())
{
if(query.value(0).toInt() < 0)
{
throw std::runtime_error("Can not delete Class Code as one or more items reference it.");
}
}
}
示例6: getMaxTabId
int DBWorker::getMaxTabId()
{
QSqlQuery query = prepare("SELECT MAX(tab_id) FROM tab");
if (execute(query)) {
if (query.first()) {
#ifdef DEBUG_LOGS
qDebug() << "read from db: " << query.value(0).toInt();
#endif
return query.value(0).toInt();
}
}
#ifdef DEBUG_LOGS
qDebug() << "query failed";
#endif
return 0;
}
示例7: getTab
void DBWorker::getTab(int tabId)
{
QSqlQuery query = prepare("SELECT tab_id, tab_history_id FROM tab WHERE tab_id = ?;");
query.bindValue(0, tabId);
if (!execute(query)) {
return;
}
if (query.first()) {
#ifdef DEBUG_LOGS
Tab tab = getTabData(query.value(0).toInt(), query.value(1).toInt());
qDebug() << query.value(0).toInt() << query.value(1).toInt() << tab.currentLink().title() << tab.currentLink().url();
#endif
emit tabAvailable(getTabData(query.value(0).toInt(), query.value(1).toInt()));
}
}
示例8: getDiskName
QString SearchDlg::getDiskName(int diskId)
{
QString sql = "SELECT name FROM Catalog_" + QString::number(catId) + " WHERE diskNo = " + QString::number(diskId) + " AND itemType = " + QString::number(DISK_ELEMENT);
//printQS(sql);
QSqlQuery *q = new QSqlQuery(dm->db);
QString result;
if (!q)
return result;
if (q->exec(sql))
{
q->first();
result = q->value(0).toString();
}
delete q;
return result;
}
示例9: checkReadableUser
bool DataBase::checkReadableUser(QString userID, QString twitterID)
{
bool result = false;
connect();
QString queryString = "SELECT readableUsers.twitterID FROM readableUsers, users WHERE readableUsers.twitterID=users.twitterID AND readableUsers.userID="+userID+" AND users.twitterID="+twitterID;
QSqlQuery checkReadableUserQuery;
checkReadableUserQuery.prepare(queryString);
checkReadableUserQuery.exec();
checkReadableUserQuery.first();
if (checkReadableUserQuery.value(0).toString() =="")
result = false;
else
result = true;
disconnect();
return result;
}
示例10: recupererId
int BDDTitre::recupererId(const QString& nomFormate)
{
QString queryStr = "Select T.Id_Titre As 'Titre' from Titre T, Relations R WHERE T.Titre_Formate='" + nomFormate + "' " ;
QSqlQuery query = madatabase.exec( queryStr );
int id = -1;
if ( query.first() )
{
QSqlRecord rec = query.record();
id = (rec.value( "Titre" ).toInt());
}
return id;
}
示例11: isUserAlreadyConnected
bool Database::isUserAlreadyConnected(QString user)
{
QSqlQuery query;
query.exec("SELECT COUNT(user) FROM information_schema.`PROCESSLIST` WHERE USER = '" + user + "'");
query.first();
if (query.value(0).toInt() != 1)
{
QMessageBox msgBox;
msgBox.setText("Same user already connected in game");
msgBox.exec();
return true;
}
else
return false;
}
示例12: GetFilterById
void Feeds::GetFilterById(filters_struct * filter)
{
QSqlQuery query;
QString prepQuery = "SELECT * FROM FILTER WHERE id = :id ";
query.prepare(prepQuery);
query.bindValue(":id", filter->id);
if(!query.exec())
{
return;
}
query.first();
filter->title = query.value(2).toString();
filter->comment = query.value(3).toString();
filter->is_on = query.value(4).toBool();
}
示例13: getSchueler
/*!
* \param vorname Vorname des Schülers.
* \param nachname Nachname des Schülers.
* \return Schüler.
*/
Schueler* Datenbank::getSchueler(QString vorname, QString nachname)
{
QSqlQuery query;
query.prepare("SELECT * FROM h_schueler WHERE vorname = :vorname AND nachname = :nachname");
query.bindValue(":vorname", vorname);
query.bindValue(":nachname", nachname);
query.exec();
Schueler *schueler = new Schueler();
query.first();
QSqlRecord record = query.record();
schueler->setSchuelerID(query.value(record.indexOf("schuelerid")).toInt());
schueler->setVorname(query.value(record.indexOf("vorname")).toString());
schueler->setNachname(query.value(record.indexOf("nachname")).toString());
schueler->setPasswort(query.value(record.indexOf("passwort")).toString());
return schueler;
}
示例14: getAgent
AgentInfo ServerManager::getAgent(const QString &id) {
AgentInfo info;
QSqlQuery query;
query.prepare("SELECT Created, PSW FROM Agents WHERE ID = ?");
query.addBindValue(id);
query.exec();
if (query.first()) {
info.created = Database::stringToDate(query.value(0).toString());
info.id = id;
info.pswDigest = query.value(1).toByteArray();
}
return info;
}
示例15: readSettings
void MessageWindow::readSettings()
{
QString configName = "messagesWindow";
QHash<QString, int> settingValues;
QSettings settings;
if (settings.status() == QSettings::NoError)
{
settings.beginGroup(configName);
if (settings.contains("x") &&
settings.contains("y") &&
settings.contains("width") &&
settings.contains("height") &&
settings.value("width", 0).toInt() > 0 &&
settings.value("height", 0).toInt() > 0)
{
settingValues.insert("x", settings.value("x").toInt());
settingValues.insert("y", settings.value("y").toInt());
settingValues.insert("width", settings.value("width").toInt());
settingValues.insert("height", settings.value("height").toInt());
}
else
{
// Если локальные значения координат и размеров окна прочитать не удалось, попытаемся загрузить их с сервера
app->showMessageOnStatusBar(tr("Загрузка с сервера геометрии окна справочника ") + configName + "...");
QSqlQuery config = app->getDBFactory()->getConfig();
config.first();
while (config.isValid())
{
if (config.record().value("group").toString() == configName)
{
settingValues.remove(config.record().value("name").toString());
settingValues.insert(config.record().value("name").toString(), config.record().value("value").toInt());
}
config.next();
}
app->showMessageOnStatusBar("");
}
settings.endGroup();
int x = settingValues.value("x", 0);
int y = settingValues.value("y", 0);
int w = settingValues.value("width", 400);
int h = settingValues.value("height", 200);
subWindow->setGeometry(x, y, w, h);
}
}