Esempio n. 1
0
QList<QVariantList> TcDataAccess::fetchAllList(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    _prepareExec(sql, bind);

    QList<QVariantList> result;
    QVariantList row;
    QSqlRecord rec;
    while (_query->next())
    {
        rec = _query->record();
        if (result.isEmpty())
        {
            for (int i = 0; i < rec.count(); i++)
            {
                row << _case(rec.fieldName(i));
            }
            result << row;
            row.clear();
        }
        for (int i = 0; i < rec.count(); i++)
        {
            row << _trim(rec.value(i));
        }
        result << row;
        row.clear();
    }
    return result;
}
Esempio n. 2
0
QVariant TcDataAccess::fetchOne(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    _prepareExec(sql, bind);
    QVariant val;
    if (_query->next())
    {
        val = _trim(_query->value(0));
    }
    return val;
}
Esempio n. 3
0
QVariantList TcDataAccess::fetchCol(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    _prepareExec(sql, bind);

    QVariantList rows;
    while (_query->next())
    {
        rows << _trim(_query->value(0));
    }
    return rows;
}
Esempio n. 4
0
int DataAccess::doDelete(const QString &table, const QString &where /* = QString() */, const QVariantList &bind /* = QVariantList() */)
{
    QString sql = "DELETE FROM " + table;
    if (!where.isEmpty())
    {
        sql += " WHERE " + where;
    }
    
    QSqlQuery *q = _prepareExec(sql, bind);
    int iNumRowsAffected = q->numRowsAffected();
    delete q;
    return iNumRowsAffected;
}
Esempio n. 5
0
QVariant DataAccess::fetchOne(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    QSqlQuery *q = _prepareExec(sql, bind);

    QVariant val;
    if (q->next())
    {
        val = q->value(0);
    }
    delete q;
    return val;
}
Esempio n. 6
0
QVariantList DataAccess::fetchCol(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    QSqlQuery *q = _prepareExec(sql, bind);

    QVariantList rows;
    while (q->next())
    {
        rows << q->value(0);
    }
    delete q;
    return rows;
}
Esempio n. 7
0
QVariantMap TcDataAccess::fetchRow(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    _prepareExec(sql, bind);

    QVariantMap row;
    if (_query->next())
    {
        QSqlRecord rec = _query->record();
        for (int i = rec.count() - 1; i > -1; i--)
        {
            row[_case(rec.fieldName(i))] = _trim(rec.value(i));
        }
    }
    return row;
}
Esempio n. 8
0
QVariantMap DataAccess::fetchRow(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    QSqlQuery *q = _prepareExec(sql, bind);

    QVariantMap row;
    if (q->next())
    {
        QSqlRecord rec = q->record();
        for (int i = rec.count() - 1; i > -1; i--)
        {
            row[rec.fieldName(i)] = rec.value(i);
        }
    }
    delete q;
    return row;
}
Esempio n. 9
0
QList<QVariantMap> TcDataAccess::fetchAll(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    _prepareExec(sql, bind);

    QList<QVariantMap> result;
    QVariantMap row;
    while (_query->next())
    {
        QSqlRecord rec = _query->record();
        for (int i = rec.count() - 1; i > -1; i--)
        {
            row[_case(rec.fieldName(i))] = _trim(rec.value(i));
        }
        result << row;
        row.clear();
    }
    return result;
}
Esempio n. 10
0
QList<QVariantMap> DataAccess::fetchAll(const QString &sql,
            const QVariantList &bind /* = QVariantList() */)
{
    QSqlQuery *q = _prepareExec(sql, bind);

    QList<QVariantMap> result;
    QVariantMap row;
    while (q->next())
    {
        QSqlRecord rec = q->record();
        for (int i = rec.count() - 1; i > -1; i--)
        {
            row[rec.fieldName(i)] = rec.value(i);
        }
        result << row;
        row.clear();
    }
    delete q;
    return result;
}