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