Example #1
0
int Database::insertState(States s)
{
    QVariant name = s.getDescription().toLower();
    if(!this->stateExist(name)){
        this->query.prepare("INSERT INTO States (name) VALUES (:name);");
        this->query.bindValue(":name",name);
        if(!this->query.exec()){
            this->showError(this->query.lastError());
            return -1;
        }
        return this->query.lastInsertId().toInt();
    }
    return 0;
}