本文整理汇总了C++中DataTable::hasRow方法的典型用法代码示例。如果您正苦于以下问题:C++ DataTable::hasRow方法的具体用法?C++ DataTable::hasRow怎么用?C++ DataTable::hasRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTable
的用法示例。
在下文中一共展示了DataTable::hasRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Profile::Profile(shared_ptr<Portal> portal, shared_ptr<IPortalDatabase> database, shared_ptr<ObjectsUser> user) : m_portal(portal),
m_user(user)
{
// Calcolo Score
DataTable result;
String sql = String::format(_S("select score, description, follow from os_snapshot_users where id='%S'").c_str(), m_user->id->toUTF16().c_str());
database->execute(sql, result);
if(result.hasRow(0))
{
// Estrae il punteggio
m_score.setValue(result.get(0, _S("score")));
// Estrae la descrizione
m_score.setDescription(result.get(0, _S("description")));
// Estrae il follow
m_score.setFollow(result.get(0, _S("follow")));
}
}
示例2: load
//bool EntitiesEntity::_loadObject(const shared_ptr<IPortalDatabase> &database, shared_ptr<ObjectsIRevisionable> object)
bool EntitiesEntity::load(const shared_ptr<IPortalDatabase> &database, const EntityID & id)
{
OS_TIMER_PERFORMANCE(TP, _S("Entity::_loadObject"));
OS_LOCK(m_cs);
#ifndef OS_TODOCIP
shared_ptr<ObjectsIRevisionable> object = objects_revisionable_cast(database->getPortal()->getObject(database, id.toUTF16()));
m_primary = object;
//OS_ASSERT(getEntityID() == id);
#endif
if(database->getPortal()->getSnapshotManager()->m_enableEnsureLoadingEntity)
database->getPortal()->getSnapshotManager()->ensure(database, id);
DataTable result;
// TOCLEAN_SNAPSHOT_SCORE
//String sql = String::format(_S("select current,visible,score,depth,parent,section,stability_date from os_snapshot_objects where reference='%S'").c_str(), m_primary->id->toUTF16().c_str());
String sql = String::format(_S("select type,current,visible,depth,parent,section,stability_date from os_snapshot_objects where entity='%S'").c_str(), id.toUTF16().c_str());
database->execute(sql, result);
if(!result.hasRow(0))
{
clear();
return false;
}
else
{
ObjectID currentID = static_cast<String>(result.get(0,_S("current"))).to_ascii();
m_type = Convert::toObjectType(static_cast<uint32>(result.get(0,_S("type"))));
m_visible = result.get(0,_S("visible"));
//m_score = *result.get(0,_S("score")); // TOCLEAN_SNAPSHOT_SCORE
m_depth = result.get(0,_S("depth"));
m_parent = static_cast<String>(result.get(0,_S("parent"))).to_ascii();
m_section = static_cast<String>(result.get(0,_S("section"))).to_ascii();
m_stabilityDate = String(result.get(0,_S("stability_date")));
if(id == ObjectsSystem::instance()->getRootID())
//m_current = objects_revisionable_cast(database->getPortal()->getObject(database, ObjectsSystem::instance()->getRootID().toObjectID()));
m_current = ObjectsSection::getRootSection();
else
{
#ifdef OS_TODOCIP
/*
if(currentID.empty())
return false;
m_current = objects_revisionable_cast(database->getPortal()->getObject(database, currentID));
if(m_current == nullptr)
return false;
*/
if(currentID.empty() == false)
m_current = objects_revisionable_cast(database->getPortal()->getObject(database, currentID));
#else
if(currentID.empty())
{
m_current.reset();
// OS_ASSERT(m_parent == ObjectsSystem::instance()->getSkippedID());
// No, dato che la getEntity non fa + l'ensure, può succedere che carica un oggetto non stabilizzato.
m_visible = false;
}
else
m_current = objects_revisionable_cast(database->getPortal()->getObject(database, currentID));
#endif
}
return true;
}
}
示例3: executeQuery
//.........这里部分代码省略.........
select->orderBy.fields.add(last_entry_date);
}
break;
case searchOrderModeVotesAverage: {
select->tables.add(DbSqlTable(DBTABLES::DISCUSSIONS_STATS_TABLE));
// Crea la join
select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::ENTITY, DBTABLES::SNAPSHOT_OBJECTS_TABLE), DbSqlField(DBTABLES::DISCUSSIONS_STATS::REFERENCE, DBTABLES::DISCUSSIONS_STATS_TABLE));
DbSqlField last_entry_date(DBTABLES::DISCUSSIONS_STATS::VOTES_AVERAGE, DBTABLES::DISCUSSIONS_STATS_TABLE);
last_entry_date.setOrder(order);
select->orderBy.fields.add(last_entry_date);
}
break;
default: OS_EXCEPTION("Unknown query order mode");
break;
}
}
uint32 searchLimit = Options::instance()->getOption<uint32>(Options::portals_options::search_limit);
if(searchLimit != 0)
{
// 0.12 RC5 - Altrimenti, setto cmq un massimo di risultati, come limite massimo ragionevole.
select->limit.setCount(searchLimit);
}
if(query->hasMaxResults())
{
// 0.13 RC2
select->limit.setCount(query->getMaxResults());
}
// Fa prima una "count" per sapere quanti risultati totali, ad esempio per calcolare le pagine del pager.
// Poi, vengono estratti solo i record che servono alla pagina attuale (se non è il primo giro di un group-mode).
select->count = true;
DataTable result;
if(database->execute(select, result))
{
OS_ASSERT(result.hasRow(0));
m_totalResults = result.get(0, 0);
if(m_totalResults > 0) // In teoria non serve rieseguire la query se non ci sono risultati...
{
// Se è in groupMode, ed è il primo passaggio, controllo se è parziale.
if( (query->getGroupMode()) && (objectsMap.empty()) )
if( (searchLimit != 0) && (m_totalResults >= searchLimit) )
m_partial = true;
// Se non è in groupMode, o è il secondo passaggio, allora filtro per il pager.
if( (!query->getGroupMode()) || (!objectsMap.empty()) )
{
uint32 limit=0;
if( (query->hasLimit()) && (query->hasMaxResults()) )
limit = std::min<uint32>(query->getLimit(), query->getMaxResults());
else if(query->hasLimit())
limit = query->getLimit();
else if(query->hasMaxResults())
limit = query->getMaxResults();
if(limit != 0)
{
select->limit.setCount(limit);
select->limit.setOffset(query->getOffset());
}
}
else
{
if(searchLimit != 0)
{
// 0.12 RC5 - Altrimenti, setto cmq un massimo di risultati, come limite massimo ragionevole.
select->limit.setCount(searchLimit);
}
}
select->count = false;
result.clear();
if(database->execute(select, result))
{
for(uint32 r = 0; r < result.rows(); r++)
{
EntityID reference = static_cast<String>(result.get(r, DBTABLES::SNAPSHOT_OBJECTS::ENTITY)).to_ascii();
if(query->getGroupMode())
{
shared_ptr<EntitiesEntity> entity = database->getPortal()->getEntity(database, reference);
if( (entity != NULL) && (entity->getCurrent() != NULL) )
{
if(ObjectsSystem::instance()->getDescriptor(entity->getObjectType())->isGroupable())
reference = static_cast<String>(result.get(r, DBTABLES::SNAPSHOT_OBJECTS::PARENT)).to_ascii();
}
}
add(reference);
}
}
}
}
}