Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active August 22, 2023 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcsee/c429e71f6b0239b83e7e307feb5927fe to your computer and use it in GitHub Desktop.
Save mcsee/c429e71f6b0239b83e7e307feb5927fe to your computer and use it in GitHub Desktop.
<?
final class Book {
private $cachedBooks;
public function getBooksFromDatabaseByTitle(string $title) {
if (!isset($this->cachedBooks[$title])) {
$this->cachedBooks[$title] =
$this->doGetBooksFromDatabaseByTitle($title);
}
return $this->cachedBooks[$title];
}
private function doGetBooksFromDatabaseByTitle(string $title) {
globalDatabase()->selectFrom('Books', 'WHERE TITLE = ' . $title);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment