aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 502e9da0..b8e22eb8 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -226,18 +226,26 @@ class EntryRepository extends EntityRepository
226 226
227 /** 227 /**
228 * Find an entry by its url and its owner. 228 * Find an entry by its url and its owner.
229 * If it exists, return the entry otherwise return false.
229 * 230 *
230 * @param $url 231 * @param $url
231 * @param $userId 232 * @param $userId
232 * 233 *
233 * @return array 234 * @return array|bool
234 */ 235 */
235 public function findOneByUrlAndUserId($url, $userId) 236 public function existByUrlAndUserId($url, $userId)
236 { 237 {
237 return $this->createQueryBuilder('e') 238 $res = $this->createQueryBuilder('e')
239 ->select('e.id, e.createdAt')
238 ->where('e.url = :url')->setParameter('url', $url) 240 ->where('e.url = :url')->setParameter('url', $url)
239 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) 241 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
240 ->getQuery() 242 ->getQuery()
241 ->getResult(); 243 ->getResult();
244
245 if (count($res) > 1) {
246 return next($res);
247 }
248
249 return false;
242 } 250 }
243} 251}