本文整理汇总了C++中QueryBuilder::getPreparedQuery方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryBuilder::getPreparedQuery方法的具体用法?C++ QueryBuilder::getPreparedQuery怎么用?C++ QueryBuilder::getPreparedQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::getPreparedQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateById
/**
* @brief Repository::updateById Updates the row associated with the given id in the database. The
* new values are in the pBindValues Qhash.
* @param id Id of the row to update.
* @param pBindValues Columns to update with their new values.
*/
void Repository::updateById(int id, QHash<QString, QVariant> pBindValues) {
QueryBuilder qb = updateByIdQB(id, pBindValues.keys());
QSqlQuery query = qb.getPreparedQuery();
bindValues(&query, pBindValues);
Database::instance()->push(query);
}
示例2: insert
/**
* @brief Repository::insert Inserts a row in the database with the query given by the QueryBuilder
* (qb) and the given bind values (pBindValues). Retrieves the id of the inserted row and sets it on
* the DBItem.
* @param item Item associated with the inserted row in the database which will be given an id once
* the insertion is successful.
* @param qb QueryBuilder holding the query which will be executed.
* @param pBindValues Holds the values to be bound with the request.
* @param db Database
* @return Id of the inserted row.
*/
int Repository::insert(DBItem *item, QueryBuilder qb, QHash<QString, QVariant> pBindValues)
{
qb.withAsSelect(qb, "id");
QSqlQuery query = qb.getPreparedQuery();
bindValues(&query, pBindValues);
int id = Database::instance()->pushPreparedWithId(query);
item->setId(id);
return id;
}