void MSqlEscapeAsAQuery(QString &query, MSqlBindings &bindings) { MSqlQuery result(MSqlQuery::InitCon()); QString q = query; QRegExp rx(QString::fromLatin1("'[^']*'|:([a-zA-Z0-9_]+)")); QVector<Holder> holders; int i = 0; while ((i = rx.indexIn(q, i)) != -1) { if (!rx.cap(1).isEmpty()) holders.append(Holder(rx.cap(0), i)); i += rx.matchedLength(); } QVariant val; QString holder; for (i = (int)holders.count() - 1; i >= 0; --i) { holder = holders[(uint)i].holderName; val = bindings[holder]; QSqlField f("", val.type()); if (val.isNull()) f.clear(); else f.setValue(val); query = query.replace((uint)holders[(uint)i].holderPos, holder.length(), result.driver()->formatValue(f)); } }
void CGLDrawingArea::Invalidate() /***************************************/ { /* Invalidate the whole window. */ Invalidate(Holder().get_allocation()); }
/*! Prepares the SQL query \a query for execution. The query may contain placeholders for binding values. Both Oracle style colon-name (e.g. \c{:surname}), and ODBC style (e.g. \c{?}) placeholders are supported; but they cannot be mixed in the same query. See the \link #details Description\endlink for examples. \sa exec(), bindValue(), addBindValue() */ bool QSqlQuery::prepare( const QString& query ) { if ( !d->sqlResult || !d->sqlResult->extension() ) return FALSE; d->sqlResult->setActive( FALSE ); d->sqlResult->setLastError( QSqlError() ); d->sqlResult->setAt( QSql::BeforeFirst ); d->sqlResult->extension()->clear(); if ( !driver() ) { #ifdef QT_CHECK_RANGE qWarning("QSqlQuery::prepare: no driver" ); #endif return FALSE; } if ( d->count > 1 ) *this = driver()->createQuery(); d->sqlResult->setQuery( query.stripWhiteSpace() ); if ( !driver()->isOpen() || driver()->isOpenError() ) { #ifdef QT_CHECK_RANGE qWarning("QSqlQuery::prepare: database not open" ); #endif return FALSE; } if ( query.isNull() || query.length() == 0 ) { #ifdef QT_CHECK_RANGE qWarning("QSqlQuery::prepare: empty query" ); #endif return FALSE; } #ifdef QT_DEBUG_SQL qDebug( "\n QSqlQuery: " + query ); #endif QString q = query; QRegExp rx(QString::fromLatin1("'[^']*'|:([a-zA-Z0-9_]+)")); if ( driver()->hasFeature( QSqlDriver::PreparedQueries ) ) { // below we substitute Oracle placeholders with ODBC ones and // vice versa to make this db independent int i = 0, cnt = 0; if ( driver()->hasFeature( QSqlDriver::NamedPlaceholders ) ) { QRegExp rx(QString::fromLatin1("'[^']*'|\\?")); while ( (i = rx.search( q, i )) != -1 ) { if ( rx.cap(0) == "?" ) { q = q.replace( i, 1, ":f" + QString::number(cnt) ); cnt++; } i += rx.matchedLength(); } } else if ( driver()->hasFeature( QSqlDriver::PositionalPlaceholders ) ) { while ( (i = rx.search( q, i )) != -1 ) { if ( rx.cap(1).isEmpty() ) { i += rx.matchedLength(); } else { // record the index of the placeholder - needed // for emulating named bindings with ODBC d->sqlResult->extension()->index[ cnt ]= rx.cap(0); q = q.replace( i, rx.matchedLength(), "?" ); i++; cnt++; } } } d->executedQuery = q; return d->sqlResult->extension()->prepare( q ); } else { int i = 0; while ( (i = rx.search( q, i )) != -1 ) { if ( !rx.cap(1).isEmpty() ) d->sqlResult->extension()->holders.append( Holder( rx.cap(0), i ) ); i += rx.matchedLength(); } return TRUE; // fake prepares should always succeed } }
GdkGLConfig* CGLDrawingArea::GLConfig() /***************************************/ { return(Holder().GLConfig()); }