Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}