本文整理汇总了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();
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
}
示例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;
}
示例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();
}