for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Stu\Orm\Repository;
use Doctrine\ORM\EntityRepository;
use Stu\Orm\Entity\KnCommentArchiv;
use Stu\Orm\Entity\KnCommentArchivInterface;
use Stu\Orm\Entity\KnPostArchivInterface;
/**
* @extends EntityRepository<KnCommentArchiv>
*/
final class KnCommentArchivRepository extends EntityRepository implements KnCommentArchivRepositoryInterface
{
public function getByPost(int $postId): array
return $this->findBy(
['post_id' => $postId],
['id' => 'desc'],
);
}
public function getAmountByPost(KnPostArchivInterface $post): int
return $this->count(['post_id' => $post, 'deleted' => null]);
public function prototype(): KnCommentArchivInterface
return new KnCommentArchiv();
public function save(KnCommentArchivInterface $comment): void
$em = $this->getEntityManager();
$em->persist($comment);
$em->flush();
public function delete(KnCommentArchivInterface $comment): void
$em->remove($comment);
public function truncateByUser(int $userId): void
$this->getEntityManager()
->createQuery(
sprintf(
'DELETE FROM %s c WHERE c.user_id = :userId',
KnCommentArchiv::class
)
->setParameters(['userId' => $userId])
->execute();