long QgsDb2Provider::featureCount() const { // Return the count that we get from the subset. if ( !mSqlWhereClause.isEmpty() ) return mNumberFeatures; // On LUW, this could be selected from syscat.tables but I'm not sure if this // is actually correct if RUNSTATS hasn't been done. // On z/OS, we don't have access to the system catalog. // Use count(*) as the easiest approach QSqlQuery query = QSqlQuery( mDatabase ); query.setForwardOnly( true ); QString sql = "SELECT COUNT(*) FROM %1.%2"; QString statement = QString( sql ).arg( mSchemaName, mTableName ); QgsDebugMsg( statement ); if ( query.exec( statement ) && query.next() ) { QgsDebugMsg( QString( "count: %1" ).arg( query.value( 0 ).toInt() ) ); return query.value( 0 ).toInt(); } else { QgsDebugMsg( "Failed" ); QgsDebugMsg( query.lastError().text() ); return -1; } }
QStringList QgsMssqlConnection::schemas( const QString &uri, QString *errorMessage ) { QgsDataSourceUri dsUri( uri ); // connect to database QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() ); if ( !openDatabase( db ) ) { if ( errorMessage ) *errorMessage = db.lastError().text(); return QStringList(); } const QString sql = QStringLiteral( "select s.name as schema_name from sys.schemas s" ); QSqlQuery q = QSqlQuery( db ); q.setForwardOnly( true ); if ( !q.exec( sql ) ) { if ( errorMessage ) *errorMessage = q.lastError().text(); return QStringList(); } QStringList result; while ( q.next() ) { const QString schemaName = q.value( 0 ).toString(); result << schemaName; } return result; }
bool QgsDb2Provider::changeGeometryValues( const QgsGeometryMap &geometry_map ) { if ( geometry_map.isEmpty() ) return true; if ( mFidColName.isEmpty() ) return false; for ( QgsGeometryMap::const_iterator it = geometry_map.constBegin(); it != geometry_map.constEnd(); ++it ) { QgsFeatureId fid = it.key(); // skip added features if ( FID_IS_NEW( fid ) ) { continue; } QString statement; statement = QString( "UPDATE %1.%2 SET %3 = " ) .arg( mSchemaName, mTableName, mGeometryColName ); if ( !mDatabase.isOpen() ) { QString errMsg; mDatabase = getDatabase( mConnInfo, errMsg ); if ( !errMsg.isEmpty() ) { return false; } } QSqlQuery query = QSqlQuery( mDatabase ); query.setForwardOnly( true ); statement += QString( "db2gse.%1(CAST (%2 AS BLOB(2M)),%3)" ) .arg( mGeometryColType, QString( "?" ), QString::number( mSRId ) ); // set attribute filter statement += QString( " WHERE %1=%2" ).arg( mFidColName, FID_TO_STRING( fid ) ); QgsDebugMsg( statement ); if ( !query.prepare( statement ) ) { QgsDebugMsg( query.lastError().text() ); return false; } // add geometry param QByteArray bytea = QByteArray(( char* )it->asWkb(), ( int ) it->wkbSize() ); query.addBindValue( bytea, QSql::In | QSql::Binary ); if ( !query.exec() ) { QgsDebugMsg( query.lastError().text() ); return false; } } return true; }
bool QgsMssqlConnection::createSchema( const QString &uri, const QString &schemaName, QString *errorMessage ) { QgsDataSourceUri dsUri( uri ); // connect to database QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() ); if ( !openDatabase( db ) ) { if ( errorMessage ) *errorMessage = db.lastError().text(); return false; } QSqlQuery q = QSqlQuery( db ); q.setForwardOnly( true ); const QString sql = QStringLiteral( "CREATE SCHEMA [%1]" ).arg( schemaName ); if ( !q.exec( sql ) ) { if ( errorMessage ) *errorMessage = q.lastError().text(); return false; } return true; }
bool QgsMssqlConnection::truncateTable( const QString &uri, QString *errorMessage ) { QgsDataSourceUri dsUri( uri ); // connect to database QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() ); const QString schema = dsUri.schema(); const QString table = dsUri.table(); if ( !openDatabase( db ) ) { if ( errorMessage ) *errorMessage = db.lastError().text(); return false; } QSqlQuery q = QSqlQuery( db ); q.setForwardOnly( true ); const QString sql = QStringLiteral( "TRUNCATE TABLE [%1].[%2]" ).arg( schema, table ); if ( !q.exec( sql ) ) { if ( errorMessage ) *errorMessage = q.lastError().text(); return false; } return true; }
bool QgsMssqlConnection::dropTable( const QString &uri, QString *errorMessage ) { QgsDataSourceUri dsUri( uri ); // connect to database QSqlDatabase db = getDatabase( dsUri.service(), dsUri.host(), dsUri.database(), dsUri.username(), dsUri.password() ); const QString schema = dsUri.schema(); const QString table = dsUri.table(); if ( !openDatabase( db ) ) { if ( errorMessage ) *errorMessage = db.lastError().text(); return false; } QSqlQuery q = QSqlQuery( db ); q.setForwardOnly( true ); const QString sql = QString( "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[%1].[%2]') AND type in (N'U')) DROP TABLE [%1].[%2]\n" "DELETE FROM geometry_columns WHERE f_table_schema = '%1' AND f_table_name = '%2'" ) .arg( schema, table ); if ( !q.exec( sql ) ) { if ( errorMessage ) *errorMessage = q.lastError().text(); return false; } return true; }
QgsCoordinateReferenceSystem QgsDb2Provider::crs() const { if ( !mCrs.isValid() && mSRId > 0 ) { mCrs.createFromSrid( mSRId ); if ( mCrs.isValid() ) { return mCrs; } // try to load crs from the database tables as a fallback QSqlQuery query = QSqlQuery( mDatabase ); query.setForwardOnly( true ); bool execOk = query.exec( QString( "SELECT DEFINITION FROM DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS WHERE SRS_ID = %1" ).arg( QString::number( mSRId ) ) ); if ( execOk && query.isActive() ) { if ( query.next() ) { mCrs = QgsCoordinateReferenceSystem::fromWkt( query.value( 0 ).toString() ); if ( mCrs.isValid() ) return mCrs; } } } return mCrs; }
QStringList SqliteDriver::tables(const QString &typeName) const { QStringList res; if (!isOpen() || !dataBase_) return res; int type = typeName.toInt(); QSqlQuery q = createQuery(); q.setForwardOnly(TRUE); #if (QT_VERSION-0 >= 0x030000) if ((type & (int)QSql::Tables) && (type & (int)QSql::Views)) q.exec("SELECT name FROM sqlite_master WHERE type='table' OR type='view'"); else if (typeName.isEmpty() || (type & (int)QSql::Tables)) q.exec("SELECT name FROM sqlite_master WHERE type='table'"); else if (type & (int)QSql::Views) q.exec("SELECT name FROM sqlite_master WHERE type='view'"); #else q.exec("SELECT name FROM sqlite_master WHERE type='table' OR type='view'"); #endif if (q.isActive()) { while (q.next()) res.append(q.value(0).toString()); } #if (QT_VERSION-0 >= 0x030000) if (type & (int)QSql::SystemTables) { // there are no internal tables beside this one: res.append("sqlite_master"); } #endif return res; }
// This should go into Qt 4.8 once we start using it for Qt Creator QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) { QMap<QString, QUrl> links; if (d->m_needsSetup) return links; const QLatin1String sqlite("QSQLITE"); const QLatin1String name("HelpManager::linksForKeyword"); DbCleaner cleaner(name); QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name); if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) { const QStringList ®isteredDocs = d->m_helpEngine->registeredDocumentations(); foreach (const QString &nameSpace, registeredDocs) { db.setDatabaseName(d->m_helpEngine->documentationFileName(nameSpace)); if (db.open()) { QSqlQuery query = QSqlQuery(db); query.setForwardOnly(true); query.exec(QString::fromLatin1(linksForKeyQuery).arg(key)); while (query.next()) { QString title = query.value(0).toString(); if (title.isEmpty()) // generate a title + corresponding path title = key + QLatin1String(" : ") + query.value(3).toString(); links.insertMulti(title, buildQUrl(query.value(1).toString(), query.value(2).toString(), query.value(3).toString(), query.value(4).toString())); } } } }
void QgsMssqlNewConnection::listDatabases() { testConnection( "master" ); listDatabase->clear(); QString queryStr = "SELECT name FROM master..sysdatabases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')"; QSqlDatabase db = QgsMssqlProvider::GetDatabase( txtService->text().trimmed(), txtHost->text().trimmed(), "master", txtUsername->text().trimmed(), txtPassword->text().trimmed() ); if ( db.open() ) { QSqlQuery query = QSqlQuery( db ); query.setForwardOnly( true ); query.exec( queryStr ); if ( !txtService->text().isEmpty() ) { listDatabase->addItem( "(from service)" ); } if ( query.isActive() ) { while ( query.next() ) { QString name = query.value( 0 ).toString(); listDatabase->addItem( name ); } listDatabase->setCurrentRow( 0 ); } db.close(); } }
QSqlIndex SqliteDriver::primaryIndex2(const QString &tblname) const { QSqlRecordInfo rec(recordInfo(tblname)); // expensive :( if (!isOpen() || !dataBase_) return QSqlIndex(); QSqlQuery q = createQuery(); q.setForwardOnly(TRUE); // finrst find a UNIQUE INDEX q.exec("PRAGMA index_list('" + tblname + "');"); QString indexname; while (q.next()) { if (q.value(2).toInt() == 1) { indexname = q.value(1).toString(); break; } } if (indexname.isEmpty()) return QSqlIndex(); q.exec("PRAGMA index_info('" + indexname + "');"); QSqlIndex index(tblname, indexname); while (q.next()) { QString name = q.value(2).toString(); QSqlVariant::Type type = QSqlVariant::Invalid; if (rec.contains(name)) type = rec.find(name).type(); index.append(QSqlField(name, type)); } return index; }
/*! Loads Custom tags under the \a key serial from the persistent storage */ void cCustomTags::load( SERIAL key ) { if ( tags_ ) tags_->clear(); QSqlQuery result; result.setForwardOnly( true ); result.prepare( "SELECT name,type,value FROM tags WHERE serial = ?" ); result.addBindValue( key ); result.exec(); while ( result.next() ) { QString name = result.value( 0 ).toString(); QString type = result.value( 1 ).toString(); QString value = result.value( 2 ).toString(); if ( !tags_ ) tags_ = new QMap<QString, cVariant>; if ( type == "String" ) tags_->insert( name, cVariant( value ) ); else if ( type == "Int" ) tags_->insert( name, cVariant( value.toInt() ) ); else if ( type == "Double" ) tags_->insert( name, cVariant( value.toDouble() ) ); } changed = false; }
void CTaskType::slotFindTask(const QString &text) { QList<QVariant> list; QSqlQuery stored; #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png"))); #endif list.append((int)actualRecords); list.append(text); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "FindTaskType", storageHashTable(list)); bool empty(false); while (stored.next()){ empty = true; } stored = execStored(currentDatabase(), "FindTaskType", storageHashTable(list)); if (empty) { fillTaskModel(stored); } #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); }
void SecurityManager::deleteUser(const QString &name) { if (isSql()) { QSqlQuery q; q.setForwardOnly(true); q.prepare("delete from trainers where name=:name"); q.bindValue(":name", name.toLower()); q.exec(); return; } Member m = member(name); assert (m.name.length() > 0); m.name[0] = ':'; //invalid character, will not get loaded when reloading database memberFile.seek(m.filepos); members[name].write(&memberFile); memberFile.flush(); playersByIp.remove(m.ip, name); authed.remove(name); members.erase(name); bannedMembers.remove(name.toLower()); if (bannedIPs.contains(m.ip) && !playersByIp.contains(m.ip)) { bannedIPs.remove(m.ip); } }
QSqlError QrSqlHelper::call_query(QrSqlQuery &query, QSqlDatabase *database /* = nullptr */) { QSqlError dbError; if (dbError.isValid()) { return dbError; } QSqlQuery qQuery = QSqlQuery(*database); qQuery.setForwardOnly(true); QTime timeQuery; timeQuery.start (); qQuery.prepare (query.query ()); query.resolve(qQuery); if (! qQuery.exec ()) { qDebug() << "query exec fail, " << query.query (); return qQuery.lastError (); } query.resolveOutput(qQuery, true); int ms = timeQuery.elapsed (); // set is print sql query statement or not if (QrSqlConfig::getInstance ()->getTraceSqlQuery ()) { qDebug() << "custom sql query "<< "(" <<ms << " ms) : " << query.query () << " by " << database; } return QSqlError(); }
QStringList SecurityManager::membersForIp(const QString &ip) { if (isSql()) { QSqlQuery q; q.setForwardOnly(true); if (SQLCreator::databaseType == SQLCreator::SQLite) { /* On SQLite, there's some bug with the qt driver probably, but here it oftens return nothing if i use '=' instead of 'like', so... */ q.prepare("select name from trainers where ip like ?"); } else { q.prepare("select name from trainers where ip=?"); } q.addBindValue(ip); q.exec(); QStringList ret; while (q.next()) { ret.push_back(q.value(0).toString()); } return ret; } return playersByIp.values(ip); }
QSqlQuery LocalDomainAccessStore::createUpdateMasterAceQuery( const std::string& sqlQuery, const MasterAccessControlEntry& updatedMasterAce) { QSqlQuery query; query.setForwardOnly(true); query.prepare(QtTypeUtil::toQt(sqlQuery)); // Add scalar fields query.bindValue(BIND_UID, QtTypeUtil::toQt(updatedMasterAce.getUid())); query.bindValue(BIND_DOMAIN, QtTypeUtil::toQt(updatedMasterAce.getDomain())); query.bindValue(BIND_INTERFACE, QtTypeUtil::toQt(updatedMasterAce.getInterfaceName())); query.bindValue(BIND_OPERATION, QtTypeUtil::toQt(updatedMasterAce.getOperation())); query.bindValue(BIND_DEFAULT_TRUSTLEVEL, updatedMasterAce.getDefaultRequiredTrustLevel()); query.bindValue(BIND_DEFAULT_CHANGETRUSTLEVEL, updatedMasterAce.getDefaultRequiredControlEntryChangeTrustLevel()); query.bindValue( BIND_DEFAULT_CONSUMERPERMISSION, updatedMasterAce.getDefaultConsumerPermission()); // Serialize list fields QByteArray consumerPermissions = serializeEnumList(updatedMasterAce.getPossibleConsumerPermissions()); QByteArray trustLevels = serializeEnumList(updatedMasterAce.getPossibleRequiredTrustLevels()); QByteArray changeTrustLevels = serializeEnumList(updatedMasterAce.getPossibleRequiredControlEntryChangeTrustLevels()); query.bindValue(BIND_POSSIBLE_CONSUMERPERMISSIONS, consumerPermissions); query.bindValue(BIND_POSSIBLE_TRUSTLEVELS, trustLevels); query.bindValue(BIND_POSSIBLE_CHANGETRUSTLEVELS, changeTrustLevels); return query; }
void MediaList::buildList() { if (db->isOpen()) { QSqlQuery query; query.setForwardOnly(true); /* ARTHUR 27/11 : NB : J'ai eu pleins de problèmes parce que les drivers de qt sont pas les bons pour sqlite 3 donc j'ai du faire les création à partir d'ici je les ai laissé parce qu'on en aura encore besoin ... NB2 : Le path n'est pas dans les champs parce que j'ai imaginé que le path = filePath+fileName maintenant c'est facile à changer QSqlQuery create = db->exec("CREATE TABLE media ( id INTEGER PRIMARY KEY, title TEXT, synopsis TEXT, date INTEGER)"); qDebug() << create.lastError(); QSqlQuery insert = db->exec("INSERT OR REPLACE INTO media (title,synopsis,date) VALUES('Leon','Great movie',1997)"); qDebug() << insert.lastError(); QSqlQuery insert2 = db->exec("INSERT OR REPLACE INTO media (title,synopsis,date) VALUES('Iron Man','Armor man',2008)"); qDebug() << insert2.lastError(); QSqlQuery update = db->exec("UPDATE media SET title= 'Independance Day', synopsis='Alien movie', date=1996 WHERE id=4"); qDebug() << update.lastError(); */ query.exec("SELECT * FROM media"); while (query.next()) { int id = query.value(0).toInt(); QString title = query.value(1).toString(); QString synopsis = query.value(2).toString(); int date = query.value(3).toInt(); Media * media = new Media(id,title, synopsis, date); mediaList->push_back((*media)); } } }
void CCustomer::slotFillPartner(const QModelIndex &index) { QList<QVariant> list; QSqlQuery stored; if (index.sibling(index.row(), 3).data().toString() == nullptr && root->index() != index){ #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png"))); #endif list.append((int)index.sibling(index.row(), 1).data().toInt()); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadOneCustomer", storageHashTable(list)); fillPartnerModel(stored); #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); } else { modelPartner->removeRows(0, modelPartner->rowCount(QModelIndex()), QModelIndex()); textEditPartnerComment->clear(); } }
QList<Accounts::AccountRecord> Accounts::GetAccounts() { AccountRecord r; QList<Accounts::AccountRecord> L; QSqlQuery query; // query.setForwardOnly(true); query.exec("select id, name, cert_file, pkey_file, ca_file from accounts"); lasterr=query.lastError(); if (lasterr.isValid()) return L; while(query.next()) { r.id = query.value(0).toUInt(); r.name = query.value(1).toString(); r.cert_file = query.value(2).toString(); r.pkey_file = query.value(3).toString(); r.CA_file = query.value(4).toString(); L<<r; } return L; }
void CTaskType::slotDeleteRecords(void) { QList<QVariant> list; QSqlQuery stored; if (currentDatabase().isOpen()) { int code = modelSelectionTask->currentIndex().sibling(modelSelectionTask->currentIndex().row(), 0).data().toUInt(); if (!modelSelectionTask->selection().isEmpty()) { CMessage answer(this, "Удаление", "Подтверждаете удаление?"); QPushButton *_delete = answer.addButton(QString("Удалить"), QMessageBox::ActionRole); QPushButton *cancel = answer.addButton(QString("Отмена"), QMessageBox::ActionRole); answer.exec(); if (answer.clickedButton() == _delete){ list.append((int)code); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "DeleteTaskType", storageHashTable(list)); stored.finish(); slotRefreshRecords(); // refresh } else if (answer.clickedButton() == cancel){ treeCppsst->clearSelection(); answer.reject(); } } else CCommunicate::showing(QString("Не удается выполнить, запись не выбрана")); } else CCommunicate::showing(QString("Не удается выполнить, база данных не доступна")); }
void SupplyProfile::retrieveSupplyData(const QString& name) { int i=0; AllocateMemory(8760); QSqlQuery query; query.setForwardOnly(true); //fetch the list for the weather location QString strSQL, strName; strName = "'" + name + "'"; strSQL = "SELECT tot FROM energy WHERE ref = "; strSQL = strSQL + strName; // strSQL.Format(_T("SELECT ambient, dir_solar, diff_solar, wind_speed, wind_dir, rh FROM climate_espr WHERE climate_site = '%s'"),site); query.exec(strSQL); if (!query.isActive()) QMessageBox::warning(this, tr("Database Error"), query.lastError().text()); //clear the data in the weather location list //navigate through the fected query result set int temp = 0; while (query.next()) { setSupplyData(i, query.value(0).toFloat()); i++; } }
void bookStorageDialog::on_submitButton_clicked() { if( lineEdit_1->text().isEmpty() || lineEdit_2->text().isEmpty() || lineEdit_3->text().isEmpty() || lineEdit_4->text().isEmpty() || lineEdit_5->text().isEmpty() || lineEdit_6->text().isEmpty() || lineEdit_7->text().isEmpty() ) { QMessageBox::warning(this, tr("入库失败"), tr("Please fullfil the informations.")); return; } // QStringList list = src.split(QRegExp("\n")); QString sql = "INSERT INTO book VALUES("; // ( 书号, 类别, 书名, 出版社, 年份, 作者, 价格, 数量 ) QString bid = lineEdit_1->text(); sql = sql + "'" + bid + "'" + ","; QString category = lineEdit_2->text(); sql = sql + "'" + category + "'" + ","; QString book_name = lineEdit_3->text(); sql = sql + "'" + book_name + "'" + ","; QString press = lineEdit_4->text(); sql = sql + "'" + press + "'" + ","; QString year = lineEdit_5->text();; sql = sql + year + ","; QString author = lineEdit_6->text();; sql = sql + "'" + author + "'" + ","; QString price = lineEdit_7->text();; sql = sql + price + ","; QString total = lineEdit_8->text();; sql = sql + total + ","; sql = sql + total + ")"; QSqlQuery query; query.setForwardOnly(true); if( query.exec(sql) ) { QMessageBox::information(this, tr("入库成功"), book_name + tr(" 入库成功")); } else { QMessageBox::warning(this, tr("入库失败"), book_name + tr(" 入库失败")); } return; }
void setProperty(QScriptValue &object, const QScriptString &name, uint, const QScriptValue & value) { if (name == str_forwardOnly) { QSqlQuery query = qscriptvalue_cast<QSqlQuery>(object.data()); query.setForwardOnly(value.toBool()); } }
QSqlQuery LocalDomainAccessStore::createGetAceQuery(const std::string& sqlQuery, const std::string& uid) { QSqlQuery query; query.setForwardOnly(true); query.prepare(QtTypeUtil::toQt(sqlQuery)); query.bindValue(BIND_UID, QtTypeUtil::toQt(uid)); return query; }
QSqlRecordInfo SqliteDriver::recordInfo2(const QString &tbl) const { if (!isOpen() || !dataBase_) return QSqlRecordInfo(); QSqlQuery q = createQuery(); q.setForwardOnly(TRUE); q.exec("SELECT * FROM " + tbl + " LIMIT 1"); return recordInfo(q); }
bool QgsDb2Provider::setSubsetString( const QString& theSQL, bool ) { QString prevWhere = mSqlWhereClause; QgsDebugMsg( theSQL ); mSqlWhereClause = theSQL.trimmed(); QString sql = QString( "SELECT COUNT(*) FROM " ); sql += QString( "%1.%2" ).arg( mSchemaName, mTableName ); if ( !mSqlWhereClause.isEmpty() ) { sql += QString( " WHERE %1" ).arg( mSqlWhereClause ); } if ( !openDatabase( mDatabase ) ) { return false; } QSqlQuery query = QSqlQuery( mDatabase ); query.setForwardOnly( true ); QgsDebugMsg( sql ); if ( !query.exec( sql ) ) { pushError( query.lastError().text() ); mSqlWhereClause = prevWhere; QgsDebugMsg( query.lastError().text() ); return false; } if ( query.isActive() && query.next() ) { mNumberFeatures = query.value( 0 ).toInt(); QgsDebugMsg( QString( "count: %1" ).arg( mNumberFeatures ) ); } else { pushError( query.lastError().text() ); mSqlWhereClause = prevWhere; QgsDebugMsg( query.lastError().text() ); return false; } QgsDataSourceUri anUri = QgsDataSourceUri( dataSourceUri() ); anUri.setSql( mSqlWhereClause ); setDataSourceUri( anUri.uri() ); mExtent.setMinimal(); emit dataChanged(); return true; }
void CCustomer::slotFillGroup(const QModelIndex &index) { QList<QVariant> list; QSqlQuery stored; #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png"))); #endif if (modelFaces->hasChildren(index)){ modelFaces->removeRows(0, modelFaces->rowCount(index), index); } list.append((int)GROUP_TYPE_CUSTOMER); list.append((int)actualRecords); list.append((int)SKIP); // parameter skip stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadAllReferenceGroups", storageHashTable(list)); fillFacesModel(index, stored); if (root->index() != index){ if(list.size() > 0) list.clear(); list.append((int)actualRecords); list.append((int)index.sibling(index.row(), 1).data(Qt::DisplayRole).toInt()); list.append(QVariant::Invalid); list.append(QVariant::Invalid); list.append(QVariant::Invalid); list.append(QVariant::Invalid); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadAllCustomers", storageHashTable(list)); fillFacesModel(index, stored); } #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); }
/** * * ERROR: BUG IN THIS METHOD NEED DEBUGGING * Prepared statements are processed using this member. * bind value is fed as a QString */ QSqlQuery MySQLConnector::runPrepQuery(QString preprdStmt,QStringList bindValues, bool isForwardOnly, bool *isSuccess) { QSqlQuery query; if(db.open()){ query.setForwardOnly(isForwardOnly); query.prepare(preprdStmt); foreach (QString str, bindValues){ query.addBindValue(bindValues); qDebug() << str; }
QSqlQuery LocalDomainAccessStore::createGetAceQuery(const std::string& sqlQuery, const std::string& domain, const std::string& interfaceName) { QSqlQuery query; query.setForwardOnly(true); query.prepare(QtTypeUtil::toQt(sqlQuery)); query.bindValue(BIND_DOMAIN, QtTypeUtil::toQt(domain)); query.bindValue(BIND_INTERFACE, QtTypeUtil::toQt(interfaceName)); return query; }