public static function getSerieById($serieId) { $result = parent::getDb()->prepare('select id, name from series where id = ?'); $result->execute(array($serieId)); if ($post = $result->fetchObject()) { return new Serie($post); } return NULL; }
public static function getTagById($tagId) { $result = parent::getDb()->prepare('select id, name from tags where id = ?'); $result->execute(array($tagId)); if ($post = $result->fetchObject()) { return new Tag($post); } return NULL; }
public static function getAuthorByBookId($bookId) { $result = parent::getDb()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors, books_authors_link where author = authors.id and book = ?'); $result->execute(array($bookId)); $authorArray = array(); while ($post = $result->fetchObject()) { array_push($authorArray, new Author($post)); } return $authorArray; }
public static function getAuthorByBookId($bookId) { $result = parent::getDb()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link where author = authors.id and book = ?'); $result->execute(array($bookId)); $authorArray = array(); while ($post = $result->fetchObject()) { array_push($authorArray, new Author($post)); } return $authorArray; }
public static function getAllLanguages() { $result = parent::getDb()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count from languages, books_languages_link where languages.id = books_languages_link.lang_code group by languages.id, books_languages_link.lang_code order by languages.lang_code'); $entryArray = array(); while ($post = $result->fetchObject()) { $language = new Language($post->id, $post->lang_code); array_push($entryArray, new Entry(Language::getLanguageString($language->lang_code), $language->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($language->getUri())), "", $post->count)); } return $entryArray; }
public static function getAllCustoms($customId) { $result = parent::getDb()->query(str_format('select {0}.id as id, {0}.value as name, count(*) as count from {0}, {1} where {0}.id = {1}.{2} group by {0}.id, {0}.value order by {0}.value', self::getTableName($customId), self::getTableLinkName($customId), self::getTableLinkColumn($customId))); $entryArray = array(); while ($post = $result->fetchObject()) { $customColumn = new CustomColumn($post->id, $post->name, $customId); array_push($entryArray, new Entry($customColumn->name, $customColumn->getEntryId(), str_format(localize("bookword", $post->count), $post->count), "text", array(new LinkNavigation($customColumn->getUri())), "", $post->count)); } return $entryArray; }
public function doSearchByCategory() { $database = GetUrlParam(DB); $out = array(); $pagequery = Base::PAGE_OPENSEARCH_QUERY; $dbArray = array(""); $d = $database; $query = $this->query; // Special case when no databases were chosen, we search on all databases if (Base::noDatabaseSelected()) { $dbArray = Base::getDbNameList(); $d = 0; } foreach ($dbArray as $key) { if (Base::noDatabaseSelected()) { array_push($this->entryArray, new Entry($key, DB . ":query:{$d}", " ", "text", array(new LinkNavigation("?" . DB . "={$d}")), "tt-header")); Base::getDb($d); } foreach (array(PageQueryResult::SCOPE_BOOK, PageQueryResult::SCOPE_AUTHOR, PageQueryResult::SCOPE_SERIES, PageQueryResult::SCOPE_TAG, PageQueryResult::SCOPE_PUBLISHER) as $key) { if (in_array($key, getCurrentOption('ignored_categories'))) { continue; } $array = $this->searchByScope($key, TRUE); $i = 0; if (count($array) == 2 && is_array($array[0])) { $total = $array[1]; $array = $array[0]; } else { $total = count($array); } if ($total > 0) { // Comment to help the perl i18n script // str_format (localize("bookword", count($array)) // str_format (localize("authorword", count($array)) // str_format (localize("seriesword", count($array)) // str_format (localize("tagword", count($array)) // str_format (localize("publisherword", count($array)) array_push($this->entryArray, new Entry(str_format(localize("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}", str_format(localize("{$key}word", $total), $total), "text", array(new LinkNavigation("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")), Base::noDatabaseSelected() ? "" : "tt-header", $total)); } if (!Base::noDatabaseSelected() && $this->useTypeahead()) { foreach ($array as $entry) { array_push($this->entryArray, $entry); $i++; if ($i > 4) { break; } } } } $d++; if (Base::noDatabaseSelected()) { Base::clearDb(); } } return $out; }
public static function getBookByDataId($dataId) { $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format from data, books ' . self::SQL_BOOKS_LEFT_JOIN . ' where data.book = books.id and data.id = ?'); $result->execute(array($dataId)); while ($post = $result->fetchObject()) { $book = new Book($post); $data = new Data($post, $book); $data->id = $dataId; $book->datas = array($data); return $book; } return NULL; }
public static function getDataByBook($book) { $out = array(); $result = parent::getDb()->prepare('select id, format, name from data where book = ?'); $result->execute(array($book->id)); while ($post = $result->fetchObject()) { array_push($out, new Data($post, $book)); } return $out; }
public static function getRatingById($ratingId) { $result = parent::getDb()->prepare('select rating from ratings where id = ?'); $result->execute(array($ratingId)); return new Rating($ratingId, $result->fetchColumn()); }
/** * Get the title of a CustomColumn by its customID * * @param integer $customId * @return string */ protected static function getTitleByCustomID($customId) { $result = parent::getDb()->prepare('SELECT name FROM custom_columns WHERE id = ?'); $result->execute(array($customId)); if ($post = $result->fetchObject()) { return $post->name; } return ""; }