本文整理汇总了C++中DatabaseConnection::fields方法的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseConnection::fields方法的具体用法?C++ DatabaseConnection::fields怎么用?C++ DatabaseConnection::fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::fields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: databaseFieldList
QStringList Project::databaseFieldList( const QString &connection, const QString &table )
{
DatabaseConnection *conn = databaseConnection( connection );
if ( !conn )
return QStringList();
return conn->fields( table );
}
示例2: saveConnections
void Project::saveConnections()
{
#ifndef QT_NO_SQL
if ( dbFile.isEmpty() ) {
QFileInfo fi( fileName() );
setDatabaseDescription( fi.baseName() + ".db" );
}
QFile f( makeAbsolute( dbFile ) );
if ( dbConnections.isEmpty() ) {
if ( f.exists() )
f.remove();
setDatabaseDescription( "" );
modified = TRUE;
return;
}
/* .db xml */
if ( f.open( IO_WriteOnly | IO_Translate ) ) {
QTextStream ts( &f );
ts.setCodec( QTextCodec::codecForName( "UTF-8" ) );
ts << "<!DOCTYPE DB><DB version=\"1.0\">" << endl;
/* db connections */
int indent = 0;
for ( DatabaseConnection *conn = dbConnections.first(); conn; conn = dbConnections.next() ) {
ts << makeIndent( indent ) << "<connection>" << endl;
++indent;
saveSingleProperty( ts, "name", conn->name(), indent );
saveSingleProperty( ts, "driver", conn->driver(), indent );
saveSingleProperty( ts, "database", conn->database(), indent );
saveSingleProperty( ts, "username", conn->username(), indent );
saveSingleProperty( ts, "hostname", conn->hostname(), indent );
saveSingleProperty( ts, "port", QString::number( conn->port() ), indent );
/* connection tables */
QStringList tables = conn->tables();
for ( QStringList::Iterator it = tables.begin();
it != tables.end(); ++it ) {
ts << makeIndent( indent ) << "<table>" << endl;
++indent;
saveSingleProperty( ts, "name", (*it), indent );
/* tables fields */
QStringList fields = conn->fields( *it );
for ( QStringList::Iterator it2 = fields.begin();
it2 != fields.end(); ++it2 ) {
ts << makeIndent( indent ) << "<field>" << endl;
++indent;
saveSingleProperty( ts, "name", (*it2), indent );
--indent;
ts << makeIndent( indent ) << "</field>" << endl;
}
--indent;
ts << makeIndent( indent ) << "</table>" << endl;
}
--indent;
ts << makeIndent( indent ) << "</connection>" << endl;
}
ts << "</DB>" << endl;
f.close();
}
#endif
}