Beispiel #1
0
/*!
    Binds the value \a val of parameter type \a paramType to position \a index
    in the current record (row).

    \sa addBindValue()
*/
void QSqlResult::bindValue(int index, const QVariant& val, QSql::ParamType paramType)
{
    d->binds = PositionalBinding;
    d->indexes[qFieldSerial(index)].append(index);
    if (d->values.count() <= index)
        d->values.resize(index + 1);
    d->values[index] = val;
    if (paramType != QSql::In || !d->types.isEmpty())
        d->types[index] = paramType;
}
Beispiel #2
0
QString QSqlResultPrivate::positionalToNamedBinding()
{
    int n = sql.size();

    QString result;
    result.reserve(n * 5 / 4);
    bool inQuote = false;
    int count = 0;

    for (int i = 0; i < n; ++i) {
        QChar ch = sql.at(i);
        if (ch == QLatin1Char('?') && !inQuote) {
            result += qFieldSerial(count++);
        } else {
            if (ch == QLatin1Char('\''))
                inQuote = !inQuote;
            result += ch;
        }
    }
    result.squeeze();
    return result;
}
Beispiel #3
0
QString QSqlResultPrivate::positionalToNamedBinding()
{
    int n = sql.size();

    QString result;
    result.reserve(n * 5 / 4);
    bool inQuote = false;
    int count = 0;

    for (int i = 0; i < n; ++i) {
        QChar ch = sql.at(i);
        if (ch == QLatin1Char('?') && !inQuote) {
            // Update the holder position since we are changing the holder name lengths
            holders[count].holderPos = result.size();
            result += qFieldSerial(count++);
        } else {
            if (ch == QLatin1Char('\''))
                inQuote = !inQuote;
            result += ch;
        }
    }
    result.squeeze();
    return result;
}
Beispiel #4
0
QString QSqlResultPrivate::holderAt(int index) const
{
    return holders.size() > index ? holders.at(index).holderName : qFieldSerial(index);
}