本文整理汇总了C++中Computer::setBuilt方法的典型用法代码示例。如果您正苦于以下问题:C++ Computer::setBuilt方法的具体用法?C++ Computer::setBuilt怎么用?C++ Computer::setBuilt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::setBuilt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
QVector<Computer> DbManager::findComputers(QString conditions)
{
db.open();
Computer temp;
QVector<Computer> results;
QSqlQuery qry;
qry.exec("PRAGMA foreign_keys=ON");
qry.exec("SELECT cID, name, year, type, built "
"FROM Computers "
+ conditions);
int i_id = qry.record().indexOf("cID");
int i_name = qry.record().indexOf("name");
int i_year = qry.record().indexOf("year");
int i_type = qry.record().indexOf("type");
int i_built = qry.record().indexOf("built");
while(qry.next())
{
temp.setId(qry.value(i_id).toString().toStdString());
temp.setName(qry.value(i_name).toString().toStdString());
temp.setYear(qry.value(i_year).toString().toStdString());
temp.setType(qry.value(i_type).toString().toStdString());
temp.setBuilt(stoi(qry.value(i_built).toString().toStdString())); //stoi to change to bool
results.push_back(temp);
}
db.close();
return results;
}
示例2: getComputer
Computer DbManager::getComputer(QString cid)
{
db.open();
Computer temp;
QSqlQuery qry;
qry.exec("PRAGMA foreign_keys=ON");
qry.exec("SELECT cID, name, year, type, built "
"FROM Computers "
"WHERE cID = " + cid);
int i_id = qry.record().indexOf("cID");
int i_name = qry.record().indexOf("name");
int i_year = qry.record().indexOf("year");
int i_type = qry.record().indexOf("type");
int i_built = qry.record().indexOf("built");
while(qry.next())
{
temp.setId(qry.value(i_id).toString().toStdString());
temp.setName(qry.value(i_name).toString().toStdString());
temp.setYear(qry.value(i_year).toString().toStdString());
temp.setType(qry.value(i_type).toString().toStdString());
temp.setBuilt(stoi(qry.value(i_built).toString().toStdString())); //stoi to change to bool
}
db.close();
return temp;
}
示例3: getComputer
Computer ComputerRepository::getComputer(const unique_ptr<QSqlQuery> &query) {
Computer comp;
comp.setID(query->value("id").toInt());
comp.setName(query->value("name").toString().toStdString());
comp.setType(query->value("type").toString().toStdString());
comp.setBuildYear(query->value("build_year").toInt());
comp.setBuilt(query->value("built").toBool());
return comp;
}
示例4: if
vector<Computer> ComputerRepository::search(string input, string word) {
db.open();
vector<Computer> temp;
QString qinput = QString::fromStdString(input);
QString likeInput = "%" + qinput + "%";
QSqlQuery query;
if(word == "Name") {
query.prepare("SELECT * FROM Computers c WHERE c.Name LIKE :contains ORDER BY Name;");
} else if(word == "Build Year") {
query.prepare("SELECT * FROM Computers c WHERE c.BuildYear LIKE :contains ORDER BY Name");
} else if(word == "Type") {
query.prepare("SELECT * FROM Computers c WHERE c.Type LIKE :contains ORDER BY Name");
} else {
query.prepare("SELECT * FROM Computers c WHERE c.Built LIKE :contains ORDER BY Name");
}
query.bindValue(":contains",likeInput);
query.exec();
while(query.next()) {
Computer c;
c.setName(query.value("Name").toString().toStdString());
c.setBuildYear(query.value("BuildYear").toString().toStdString());
c.setType(query.value("Type").toString().toStdString());
c.setBuilt(query.value("Built").toInt());
c.setID(query.value("ID").toInt());
temp.push_back(c);
}
db.close();
return temp;
}
示例5: while
vector<Computer> ComputerRepository::getComputersFromScientist(Person scientist) {
db.open();
vector<Computer> temp;
QSqlQuery query;
query.prepare("SELECT * FROM Computers c JOIN Linker l ON l.c_ID = c.ID AND l.p_ID = ?");
query.addBindValue(scientist.getID());
query.exec();
while(query.next()) {
Computer c;
c.setName(query.value("Name").toString().toStdString());
c.setBuildYear(query.value("BuildYear").toString().toStdString());
c.setType(query.value("Type").toString().toStdString());
c.setBuilt(query.value("Built").toInt());
c.setID(query.value("ID").toInt());
temp.push_back(c);
}
db.close();
return temp;
}