Created
May 24, 2021 11:38
-
-
Save SilentKernel/800f89b6d37ed46df6bf1b155deb17f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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