コード例 #1
0
ファイル: database.cpp プロジェクト: gavaza/pacca
Users Database::fillUser()
{
    Users u;
    this->query.first();
    this->record = this->query.record();
    u.setId(this->query.value(this->record.indexOf("id")));
    u.setName(this->query.value(this->record.indexOf("name")));
    return u;
}
コード例 #2
0
ファイル: database.cpp プロジェクト: gavaza/pacca
QList<Users> Database::getAllUsers()
{
    QList<Users> users;
    this->query.prepare("Select * FROM Users ORDER BY Users.name;");
    if(!this->query.exec()){
        this->showError(this->query.lastError());
        return users;
    }
    while(this->query.next()){
        Users u;
        u.setId(this->query.value(0));
        u.setName(this->query.value(1));
        users.push_back(u);
    }
    return users;
}