Author can now be searched by sort or by name (Carroll, Lewis or Lewis Carroll will work). fix #155
This commit is contained in:
parent
d45bbb7ff6
commit
15e78a852a
3 changed files with 42 additions and 1 deletions
|
@ -13,6 +13,7 @@ class Author extends Base {
|
|||
|
||||
const AUTHOR_COLUMNS = "authors.id as id, authors.name as name, authors.sort as sort, count(*) as count";
|
||||
const SQL_AUTHORS_BY_FIRST_LETTER = "select {0} from authors, books_authors_link where author = authors.id and upper (authors.sort) like ? group by authors.id, authors.name, authors.sort order by sort";
|
||||
const SQL_AUTHORS_FOR_SEARCH = "select {0} from authors, books_authors_link where author = authors.id and (upper (authors.sort) like ? or upper (authors.name) like ?) group by authors.id, authors.name, authors.sort order by sort";
|
||||
const SQL_ALL_AUTHORS = "select {0} from authors, books_authors_link where author = authors.id group by authors.id, authors.name, authors.sort order by sort";
|
||||
|
||||
public $id;
|
||||
|
@ -64,6 +65,10 @@ order by substr (upper (sort), 1, 1)');
|
|||
return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
|
||||
}
|
||||
|
||||
public static function getAuthorsForSearch($query) {
|
||||
return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
|
||||
}
|
||||
|
||||
public static function getAllAuthors() {
|
||||
return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue