[eluser]OverZealous[/eluser]
[quote author="emorling" date="1253112372"]What's the easiest way to find out if the shelf has a SPECIFIC book?
[/quote]
This is the least amount of queries, and it looks up the book at the same time:
Code:
$shelf = ... // Look up shelf
$book = $shelf->book->get_by_id(1); // Look up Book
if($book->exists()) {
// Shelf contains book
} else {
// Shelf does not contain book, you might need to re-query book
$new_book = new Book();
$new_book->get_by_id(1); (for example)
}