本文整理汇总了C++中People::setId方法的典型用法代码示例。如果您正苦于以下问题:C++ People::setId方法的具体用法?C++ People::setId怎么用?C++ People::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类People
的用法示例。
在下文中一共展示了People::setId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertNewPeople
/**
* @brief Adds a person to the database.
* Should not be called directly.
*
* @param People
* @return bool
*/
bool DatabaseManager::insertNewPeople(People &people)
{
QSqlQuery l_query(m_db);
// If a people with the same name exist, we update it
// else we insert
if(existPeople(people.name())) {
Macaw::DEBUG("[DatabaseManager.insertNewPeople] Name already known");
People l_peopleToUpdate = getOnePeopleByName(people.name());
people.setId(l_peopleToUpdate.id());
if(!updatePeople(people)) {
return false;
}
} else {
l_query.prepare("INSERT INTO people ("
"name, "
"birthday, "
"biography, "
"imported, "
"id_tmdb "
") VALUES ("
":name, "
":birthday, "
":biography, "
":imported, "
":id_tmdb "
")"
);
l_query.bindValue(":name", people.name());
l_query.bindValue(":birthday", people.birthday().toString(DATE_FORMAT));
l_query.bindValue(":biography", people.biography());
l_query.bindValue(":imported", people.isImported());
l_query.bindValue(":id_tmdb", people.tmdbId());
if (!l_query.exec()) {
Macaw::DEBUG("In insertNewPeople():");
Macaw::DEBUG(l_query.lastError().text());
return false;
}
people.setId(l_query.lastInsertId().toInt());
}
return true;
}