]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntryRepository.php
Use created_at as default sort
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntryRepository.php
index 8704a2a6d2fb1062f3b17c2b36b016349c55d563..61be5220149771143f573aa27127fb461b9f9a6f 100644 (file)
@@ -22,7 +22,7 @@ class EntryRepository extends EntityRepository
         return $this->createQueryBuilder('e')
             ->leftJoin('e.user', 'u')
             ->andWhere('u.id = :userId')->setParameter('userId', $userId)
-            ->orderBy('e.id', 'desc')
+            ->orderBy('e.createdAt', 'desc')
         ;
     }
 
@@ -332,14 +332,15 @@ class EntryRepository extends EntityRepository
 
     /**
      * Remove all entries for a user id.
-     * Used when a user want to reset all informations
+     * Used when a user want to reset all informations.
      *
-     * @param  int $userId
+     * @param int $userId
      */
     public function removeAllByUserId($userId)
     {
         $this->getEntityManager()
-            ->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = '.$userId)
+            ->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = :userId')
+            ->setParameter('userId', $userId)
             ->execute();
     }
 }