mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-15 19:42:08 +00:00
Change the way to check for an existing entry
The repository method return the entry found or false if nothing exists.
This commit is contained in:
parent
27a8708b67
commit
5a4bbcc9a7
4 changed files with 20 additions and 12 deletions
|
@ -226,18 +226,26 @@ class EntryRepository extends EntityRepository
|
|||
|
||||
/**
|
||||
* Find an entry by its url and its owner.
|
||||
* If it exists, return the entry otherwise return false.
|
||||
*
|
||||
* @param $url
|
||||
* @param $userId
|
||||
*
|
||||
* @return array
|
||||
* @return array|bool
|
||||
*/
|
||||
public function findOneByUrlAndUserId($url, $userId)
|
||||
public function existByUrlAndUserId($url, $userId)
|
||||
{
|
||||
return $this->createQueryBuilder('e')
|
||||
$res = $this->createQueryBuilder('e')
|
||||
->select('e.id, e.createdAt')
|
||||
->where('e.url = :url')->setParameter('url', $url)
|
||||
->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
if (count($res) > 1) {
|
||||
return next($res);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue