示例#1
0
Podcast PodcastBackend::GetSubscriptionById(int id) {
  Podcast ret;

  QMutexLocker l(db_->Mutex());
  QSqlDatabase db(db_->Connect());

  QSqlQuery q("SELECT ROWID, " + Podcast::kColumnSpec +
                  " FROM podcasts"
                  " WHERE ROWID = :id",
              db);
  q.bindValue(":id", id);
  q.exec();
  if (!db_->CheckErrors(q) && q.next()) {
    ret.InitFromQuery(q);
  }

  return ret;
}
示例#2
0
Podcast PodcastBackend::GetSubscriptionByUrl(const QUrl& url) {
  Podcast ret;

  QMutexLocker l(db_->Mutex());
  QSqlDatabase db(db_->Connect());

  QSqlQuery q("SELECT ROWID, " + Podcast::kColumnSpec +
                  " FROM podcasts"
                  " WHERE url = :url",
              db);
  q.bindValue(":url", url.toEncoded());
  q.exec();
  if (!db_->CheckErrors(q) && q.next()) {
    ret.InitFromQuery(q);
  }

  return ret;
}
示例#3
0
PodcastList PodcastBackend::GetAllSubscriptions() {
  PodcastList ret;

  QMutexLocker l(db_->Mutex());
  QSqlDatabase db(db_->Connect());

  QSqlQuery q("SELECT ROWID, " + Podcast::kColumnSpec + " FROM podcasts", db);
  q.exec();
  if (db_->CheckErrors(q)) return ret;

  while (q.next()) {
    Podcast podcast;
    podcast.InitFromQuery(q);
    ret << podcast;
  }

  return ret;
}