当前位置: 首页>>代码示例>>C++>>正文


C++ QSqlQuery::driver方法代码示例

本文整理汇总了C++中QSqlQuery::driver方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlQuery::driver方法的具体用法?C++ QSqlQuery::driver怎么用?C++ QSqlQuery::driver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSqlQuery的用法示例。


在下文中一共展示了QSqlQuery::driver方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetID

int GetID(QString Gen_Mame){
    QSqlQuery query;
    query.driver();
    query.exec("select gen_id("+Gen_Mame+", 1) as ID FROM rdb$g_dataBase");
    query.next();
    return query.value(0).toInt();
}
开发者ID:sergey4475,项目名称:profi,代码行数:7,代码来源:sqlmodules.cpp

示例2: isUserIdExist

bool JSQLUserInfoDB::isUserIdExist(JID id){
	QSqlQuery query;
	PREPARE( query ,
			"select * from userinfo "
			"where user_id = :userId" ,
			false );
	
	query.bindValue(":userId", id);
	
	EXEC( query , false );
	
	if( query.driver()->hasFeature(QSqlDriver::QuerySize) ){
		if(query.size() > 0){
			return true;
		}else{
			return false;
		}
	}else{
		if(query.next()){
			return true;
		}else{
			return false;
		}
	}
}
开发者ID:kubuntu,项目名称:Dlut-Game-Platform,代码行数:25,代码来源:jsqluserinfodb.cpp

示例3: isGameIdExist

bool JSQLGameInfoDB::isGameIdExist(JID id)
{
	QSqlQuery query;
	PREPARE( query ,
			"select game_id from gameinfo "
			"where game_id= :gameID" ,
			false );
	
	query.bindValue(":gameID", id);
	
	EXEC( query , false );
	
	if( query.driver()->hasFeature(QSqlDriver::QuerySize) ){
		if(query.size() > 0){
			return true;
		}else{
			return false;
		}
	}else{
		if(query.next()){
			return true;
		}else{
			return false;
		}
	}
}
开发者ID:kubuntu,项目名称:Dlut-Game-Platform,代码行数:26,代码来源:jsqlgameinfodb.cpp

示例4: recordInfo

QSqlRecordInfo QMYSQLDriver::recordInfo( const QSqlQuery& query ) const
{
    QSqlRecordInfo info;
    if ( !isOpen() )
	return info;
    if ( query.isActive() && query.isSelect() && query.driver() == this ) {
	QMYSQLResult* result =  (QMYSQLResult*)query.result();
	QMYSQLResultPrivate* p = result->d;
	if ( !mysql_errno( p->mysql ) ) {
	    for ( ;; ) {
		MYSQL_FIELD* field = mysql_fetch_field( p->result );
		if ( field ) {
		    info.append ( QSqlFieldInfo( QString( field->name ),
				qDecodeMYSQLType( (int)field->type, field->flags ),
				IS_NOT_NULL( field->flags ),
				(int)field->length,
				(int)field->decimals,
				QVariant(),
				(int)field->type ) );
		
		} else
		    break;
	    }
	}
	mysql_field_seek( p->result, 0 );
    }
    return info;
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:28,代码来源:qsql_mysql.cpp

示例5: recordInfo

QSqlRecordInfo QSQLiteDriver::recordInfo(const QSqlQuery& query) const
{
    if (query.isActive() && query.driver() == this) {
        QSQLiteResult* result = (QSQLiteResult*)query.result();
        return result->d->rInf;
    }
    return QSqlRecordInfo();
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:8,代码来源:qsql_sqlite.cpp

示例6: setQuery

/*!
    Resets the model and sets the data provider to be the given \a
    query. Note that the query must be active and must not be
    isForwardOnly().

    lastError() can be used to retrieve verbose information if there
    was an error setting the query.

    \sa query(), QSqlQuery::isActive(), QSqlQuery::setForwardOnly(), lastError()
*/
void QSqlQueryModel::setQuery(const QSqlQuery &query)
{
    Q_D(QSqlQueryModel);
    QSqlRecord newRec = query.record();
    bool columnsChanged = (newRec != d->rec);
    bool hasQuerySize = query.driver()->hasFeature(QSqlDriver::QuerySize);
    bool hasNewData = (newRec != QSqlRecord()) || !query.lastError().isValid();

    if (d->colOffsets.size() != newRec.count() || columnsChanged)
        d->initColOffsets(newRec.count());

    bool mustClearModel = d->bottom.isValid();
    if (mustClearModel) {
        d->atEnd = true;
        beginRemoveRows(QModelIndex(), 0, qMax(d->bottom.row(), 0));
        d->bottom = QModelIndex();
    }

    d->error = QSqlError();
    d->query = query;
    d->rec = newRec;

    if (mustClearModel)
        endRemoveRows();

    d->atEnd = false;

    if (columnsChanged && hasNewData)
        reset();

    if (!query.isActive() || query.isForwardOnly()) {
        d->atEnd = true;
        d->bottom = QModelIndex();
        if (query.isForwardOnly())
            d->error = QSqlError(QLatin1String("Forward-only queries "
                                               "cannot be used in a data model"),
                                 QString(), QSqlError::ConnectionError);
        else
            d->error = query.lastError();
        return;
    }
    QModelIndex newBottom;
    if (hasQuerySize && d->query.size() > 0) {
        newBottom = createIndex(d->query.size() - 1, d->rec.count() - 1);
        beginInsertRows(QModelIndex(), 0, qMax(0, newBottom.row()));
        d->bottom = createIndex(d->query.size() - 1, columnsChanged ? 0 : d->rec.count() - 1);
        d->atEnd = true;
        endInsertRows();
    } else {
        newBottom = createIndex(-1, d->rec.count() - 1);
    }
    d->bottom = newBottom;

    queryChange();

    // fetchMore does the rowsInserted stuff for incremental models
    fetchMore();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:68,代码来源:qsqlquerymodel.cpp

示例7: qb

    Q_FOREACH (const Flag &flag, flags) {
        QSet<PimItem::Id> existing;
        if (checkIfExists) {
            QueryBuilder qb(PimItemFlagRelation::tableName(), QueryBuilder::Select);
            Query::Condition cond;
            cond.addValueCondition(PimItemFlagRelation::rightColumn(), Query::Equals, flag.id());
            cond.addValueCondition(PimItemFlagRelation::leftColumn(), Query::In, itemsIds);
            qb.addColumn(PimItemFlagRelation::leftColumn());
            qb.addCondition(cond);

            if (!qb.exec()) {
                qCDebug(AKONADISERVER_LOG) << "Failed to execute query:" << qb.query().lastError();
                return false;
            }

            QSqlQuery query = qb.query();
            if (query.driver()->hasFeature(QSqlDriver::QuerySize)) {
                //The query size feature is not suppoerted by the sqllite driver
                if (query.size() == items.count()) {
                    continue;
                }
                setBoolPtr(flagsChanged, true);
            }

            while (query.next()) {
                existing << query.value(0).value<PimItem::Id>();
            }
            if (!query.driver()->hasFeature(QSqlDriver::QuerySize)) {
                if (existing.size() != items.count()) {
                    setBoolPtr(flagsChanged, true);
                }
            }
        }

        if (!doAppendItemsFlag(items, flag, existing, col, silent)) {
            return false;
        }
    }
开发者ID:KDE,项目名称:akonadi,代码行数:38,代码来源:datastore.cpp

示例8: record

QSqlRecord QMYSQLDriver::record( const QSqlQuery& query ) const
{
    QSqlRecord fil;
    if ( !isOpen() )
	return fil;
    if ( query.isActive() && query.isSelect() && query.driver() == this ) {
	QMYSQLResult* result =  (QMYSQLResult*)query.result();
	QMYSQLResultPrivate* p = result->d;
	if ( !mysql_errno( p->mysql ) ) {
	    for ( ;; ) {
		MYSQL_FIELD* f = mysql_fetch_field( p->result );
		if ( f ) {
		    QSqlField fi( QString((const char*)f->name), qDecodeMYSQLType( f->type, f->flags ) );
		    fil.append( fi  );
		} else
		    break;
	    }
	}
	mysql_field_seek( p->result, 0 );
    }
    return fil;
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:22,代码来源:qsql_mysql.cpp

示例9: populateFromResult

void Graph::populateFromResult(QSqlQuery & qry) {
    bool valid = FALSE;
    bool old_repaint = autoRepaint();
    setAutoRepaint(FALSE);
    QVariant var;
    double val;
    int cols = qry.driver()->record(qry).count();
    while(qry.next()) {
        if(!qry.isNull(0)) {
            setReferenceLabel(qry.at(), qry.value(0).toString());
        }
        for(int c = 1; c < cols; c++) {
            if(!qry.isNull(c)) {
                val = qry.value(c).toDouble(&valid);
                if(valid) {
                    setSetValue(qry.at(), c - 1, val);
                }
            }
        }
    }
    setAutoRepaint(old_repaint);
    if(autoRepaint()) repaint();
}
开发者ID:Wushaowei001,项目名称:xtuple,代码行数:23,代码来源:graph.cpp


注:本文中的QSqlQuery::driver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。