int FormMain::dbSaveFolder( const QDir & dir, int parent_id ) const { QSqlQuery q; q.prepare("INSERT INTO folders (" "parent_id, " "name, " "path, " "size " ") VALUES (" ":pid, " ":nam, " ":pat, " ":siz )"); q.bindValue(":pid", parent_id ); q.bindValue(":nam", dir.dirName().isEmpty() ? dir.rootPath() : dir.dirName() ); q.bindValue(":pat", dir.absolutePath() ); q.bindValue(":siz", 0 ); // void dbSaveFolderSize( int folder_id, qint64 size ) const if ( q.exec() ) { q.prepare("SELECT last_insert_rowid()"); if ( q.exec() ) { if ( q.first() ) return q.value( 0 ).toInt(); else return -1; } else { emit yell( q.lastError().text() ); return -1; } } else { emit yell( q.lastError().text() ); return -1; } }