本文整理汇总了C++中DataTable::columns方法的典型用法代码示例。如果您正苦于以下问题:C++ DataTable::columns方法的具体用法?C++ DataTable::columns怎么用?C++ DataTable::columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTable
的用法示例。
在下文中一共展示了DataTable::columns方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: queryValue
DataItem IDbConnection::queryValue(const String &sql)
{
DataItem value;
DataTable result;
if(query(sql, result))
if(result.rows() > 0 && result.columns() > 0)
value = *result[0][0];
return value;
}
示例2: value_of
uint32 IDbConnection::value_of(const String &sql) // TOCLEAN, rimpiazzare con la queryValue
{
DataTable result;
if(query(sql, result) == false)
return false;
uint32 value = 0;
if(result.rows() > 0 && result.columns() > 0)
value = *result[0][0];
return value;
}
示例3: onPreRender
void IdeTableQuery::onPreRender()
{
ControlBase::onPreRender();
shared_ptr<XMLDocument> document = getDocument();
shared_ptr<XMLNode> node_root = document->create(_S("table_query"));
DataTable result;
if(getPage()->getDatabase()->execute(m_sql,result))
{
shared_ptr<XMLNode> node_header = node_root->addChild(_S("header"));
for(uint32 c = 0; c < result.columns(); c++)
{
String columnTitle = getColumnTitle(c);
if(columnTitle.empty())
columnTitle = result.getColumnName(c);
shared_ptr<XMLNode> node_column = node_header->addChild(_S("column"));
node_column->setAttributeString(_S("name"), columnTitle);
switch(getColumnType(c))
{
case IdeTableQuery::ctString:
{
node_column->setAttributeString(_S("type"), _S("string"));
} break;
case IdeTableQuery::ctScore:
{
node_column->setAttributeString(_S("type"), _S("score"));
} break;
case IdeTableQuery::ctEntityID:
{
node_column->setAttributeString(_S("type"), _S("entity-id"));
} break;
case IdeTableQuery::ctObjectID:
{
node_column->setAttributeString(_S("type"), _S("object-id"));
} break;
case IdeTableQuery::ctUserID:
{
node_column->setAttributeString(_S("type"), _S("user-id"));
} break;
case IdeTableQuery::ctShortDateTime:
{
node_column->setAttributeString(_S("type"), _S("short-datetime"));
} break;
case IdeTableQuery::ctLongDateTime:
{
node_column->setAttributeString(_S("type"), _S("long-datetime"));
} break;
}
}
shared_ptr<XMLNode> node_data = node_root->addChild(_S("data"));
for(uint32 r=0;r<result.rows();r++)
{
shared_ptr<XMLNode> node_data_row = node_data->addChild(_S("row"));
for(uint32 c=0;c<result.columns();c++)
{
shared_ptr<XMLNode> node_data_row_item = node_data_row->addChild(_S("item"));
String value = result.get(r,c);
switch(getColumnType(c))
{
case IdeTableQuery::ctScore:
{
node_data_row_item->setAttributeString(_S("value"), String::format(_S("%1.1f").c_str(), double(result.get(r,c))));
} break;
case IdeTableQuery::ctEntityID:
{
// Sbagliata
shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(node_data_row_item, getPage(), XMLPortalExporter::emLite));
shared_ptr<ObjectsIObject> object = getPage()->getObject(value.to_ascii());
if(object != nullptr)
{
object->exportXML(exporter);
}
} break;
case IdeTableQuery::ctObjectID:
{
shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(node_data_row_item, getPage(), XMLPortalExporter::emLite));
shared_ptr<ObjectsIObject> object = getPage()->getObject(value.to_ascii());
if(object != nullptr)
{
object->exportXML(exporter);
}
} break;
case IdeTableQuery::ctUserID:
{
shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(node_data_row_item, getPage(), XMLPortalExporter::emLite));
shared_ptr<ObjectsIObject> object = getPage()->getObject(value.to_ascii());
if(object != nullptr)
{
object->exportXML(exporter);
}
//.........这里部分代码省略.........
示例4: executeQuery
//.........这里部分代码省略.........
if( (query->getByUser().empty() == false) && (query->getByUser() != _S("*")) )
{
String user = query->getByUser();
// MySelf test
if(user == _S("myself"))
{
// VERYURGENTRAZOR: Commentata perchè ho piallato il loggedUser come parametro... rivalutare la cosa
/*
if( (loggedUser != nullptr) && loggedUser->isLogged() && (loggedUser->getGuestMode() == false))
{
user = loggedUser->getUser()->id->toUTF16();
}
else
{
user == String::EMPTY;
}
*/
user == String::EMPTY;
}
else
{
// VERYURGENT, un test migliore per verificare se è un ID?
// VERYURGENT, l'sql potrebbe essere Sqlite-specifica.
// Fatto meglio, dovrei avere un'altro combo "localizza per" "nick/id"
// Inoltre qui ci sarebbe da supportare una ricerca "non exact-match" per farlo stile Invision.
if(user.length() != 48)
{
algorithms::to_upper(user);
String sql = String::format(_S("select rs.id from os_snapshot_users ts, os_users tu where ts.id=tu.id and upper(tu.name) = %S").c_str(), Convert::toSQL(user).c_str());
DataTable result;
if(database->execute(sql, result))
{
if(result.rows() > 0 && result.columns() > 0)
user = static_cast<String>(*result[0][0]);
}
}
}
// Come autore della primaria
select->tables.add(DbSqlTable(DBTABLES::ENTRIES_TABLE));
// Crea la join
select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::ENTITY, DBTABLES::SNAPSHOT_OBJECTS_TABLE), DbSqlField(DBTABLES::ENTRIES::ID, DBTABLES::ENTRIES_TABLE));
select->where.add(DbSqlField(DBTABLES::ENTRIES::AUTHOR, DBTABLES::ENTRIES_TABLE), Convert::toSQL(user));
// Come editore dell'oggetto
// where DBTABLES::SNAPSHOT_OBJECTS::REFERENCE in (select id from os_entries where revision= getByUser();
}
}
else
{
// Se objectsList valorizzata, allora il secondo passo di una ricerca in groupMode, gli passo l'elenco oggetti.
StringList objectsList;
for(StringMap::const_iterator i = objectsMap.begin(); i != objectsMap.end(); ++i)
{
objectsList.push_back(_S("'") + i->first + _S("'"));
}
//select->where.add(String(DBTABLES::SNAPSHOT_OBJECTS_TABLE) + _S(".") + DBTABLES::SNAPSHOT_OBJECTS::REFERENCE, objectsList);
select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::ENTITY, DBTABLES::SNAPSHOT_OBJECTS_TABLE), objectsList);
}
// Se il primo passaggio di una groupMode, l'ordinamento inutile.
// 0.12 RC5, tolto, con un limite nel primo giro di group-mode, devono essere ordinati.
//if( (!query->getGroupMode()) || (!objectsMap.empty()) )