Example #1
0
Books BookManager::getBooksByAuthor(const std::string& author)
{
  tntdb::Statement sel = _conn.prepare(
      "select isbn, title, author, price"
      "  from book"
      " where author like :author");

  sel.set("author", '%' + author + '%');

  Books books;

  for (tntdb::Statement::const_iterator cur = sel.begin(); cur != sel.end(); ++cur)
  {
    tntdb::Row r = *cur;

    books.push_back(Book());
    Book& book = books.back();

    r[0].get(book._isbn);
    r[1].get(book._title);
    r[2].get(book._author);
    r[3].get(book._price);
  }

  return books;
}