本文整理汇总了C++中TomahawkSqlQuery::lastError方法的典型用法代码示例。如果您正苦于以下问题:C++ TomahawkSqlQuery::lastError方法的具体用法?C++ TomahawkSqlQuery::lastError怎么用?C++ TomahawkSqlQuery::lastError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TomahawkSqlQuery
的用法示例。
在下文中一共展示了TomahawkSqlQuery::lastError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fi
void
DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
{
qDebug() << Q_FUNC_INFO;
Q_ASSERT( !source().isNull() );
int deleted = 0;
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
TomahawkSqlQuery delquery = dbi->newquery();
QString lastPath;
if ( !m_dir.path().isEmpty() && source()->isLocal() )
{
qDebug() << "Deleting" << m_dir.path() << "from db for localsource" << srcid;
TomahawkSqlQuery dirquery = dbi->newquery();
dirquery.prepare( QString( "SELECT id, url FROM file WHERE source %1 AND url LIKE ?" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) );
delquery.prepare( QString( "DELETE FROM file WHERE source %1 AND id = ?" )
.arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) ) );
dirquery.bindValue( 0, "file://" + m_dir.canonicalPath() + "/%" );
dirquery.exec();
while ( dirquery.next() )
{
QFileInfo fi( dirquery.value( 1 ).toString().mid( 7 ) ); // remove file://
if ( fi.canonicalPath() != m_dir.canonicalPath() )
{
if ( lastPath != fi.canonicalPath() )
qDebug() << "Skipping subdir:" << fi.canonicalPath();
lastPath = fi.canonicalPath();
continue;
}
m_ids << dirquery.value( 0 ).toUInt();
m_files << dirquery.value( 1 ).toString();
}
foreach ( const QVariant& id, m_ids )
{
delquery.bindValue( 0, id.toUInt() );
if( !delquery.exec() )
{
qDebug() << "Failed to delete file:"
<< delquery.lastError().databaseText()
<< delquery.lastError().driverText()
<< delquery.boundValues();
continue;
}
deleted++;
}