Update BookmarkMapper.php
This commit is contained in:
parent
4d87d388b8
commit
3ea424693b
@ -37,18 +37,21 @@ class BookmarkMapper extends ReaderMapper {
|
||||
* @return array
|
||||
*/
|
||||
public function get($fileId, $name, $type = null) {
|
||||
$sql = "SELECT * FROM `*PREFIX*reader_bookmarks` WHERE file_id=? AND `user_id`=?";
|
||||
$args = [ $fileId, $this->userId ];
|
||||
if (!(null === $type)) {
|
||||
$sql .= " AND `type`=?";
|
||||
$args[] = $type;
|
||||
}
|
||||
if (!(null === $name)) {
|
||||
$sql .= " AND `name`=?";
|
||||
$args[] = $name;
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from($this->getTableName())
|
||||
->where($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
|
||||
->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($this->userId)));
|
||||
|
||||
if ($type !== null) {
|
||||
$query->andWhere($query->expr()->eq('type', $query->createNamedParameter($type)));
|
||||
}
|
||||
|
||||
return $this->findEntities($sql, $args);
|
||||
if ($name !== null) {
|
||||
$query->andWhere($query->expr()->eq('name', $query->createNamedParameter($name)));
|
||||
}
|
||||
|
||||
return $this->findEntities($query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user