Commit 3740f311 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout du type dans la recherche d'individu

parent b1063c02
Loading
Loading
Loading
Loading
+6 −1
Changes for module/Application/src/Application/Entity/Db/Repository/IndividuRepository.php: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -25,11 +25,12 @@ class IndividuRepository extends DefaultEntityRepository
     * Recherche d'individu, en SQL pure.
     *
     * @param string  $text
     * @param string  $type (doctorant, acteur, ...)
     * @param integer $limit
     *
     * @return array
     */
    public function findByText($text, $limit = 100)
    public function findByText($text, $type = null, $limit = 100)
    {
        if (strlen($text) < 2) return [];

@@ -37,6 +38,10 @@ class IndividuRepository extends DefaultEntityRepository
        $criteres = explode(' ', $text);

        $sql = sprintf('SELECT * FROM INDIVIDU i JOIN INDIVIDU_RECH ir on ir.id = i.id WHERE rownum <= %s ', (int)$limit);
        if ($type !== null) {
            $sql = sprintf('SELECT * FROM INDIVIDU i JOIN INDIVIDU_RECH ir on ir.id = i.id WHERE i.type = \'%s\' AND  rownum <= %s ', $type, (int)$limit);
            $tmp = null;
        }
        $sqlCri  = [];

        foreach ($criteres as $c) {