Skip to content

Instantly share code, notes, and snippets.

@SilentKernel
Created May 24, 2021 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilentKernel/800f89b6d37ed46df6bf1b155deb17f0 to your computer and use it in GitHub Desktop.
Save SilentKernel/800f89b6d37ed46df6bf1b155deb17f0 to your computer and use it in GitHub Desktop.
<?php
namespace App\Repository;
class BlogArticleRepository extends ServiceEntityRepository
{
// ... BLABLABLA
/*
Attention, cette requête est uniquement basé sur les anciens slugs et rien d'autre !
*/
public function getByOldSlug(string $slug)
{
$query = $this->createQueryBuilder('ba')
->where("JSON_CONTAINS(ba.oldSlugs, :slugValue) = 1") // ça ne fonctionne que si vous avez l'extension doctrine scienta/doctrine-json-function
->setParameter('slugValue', '"'.$slug.'"')
->getQuery();
return $query->getOneOrNullResult();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment