Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 97c27045

Přidáno uživatelem Jan Šedivý před téměř 6 roky(ů)

Re #7327 Regulární výraz pro ignorování speciálních znaků při vyhledávání

Zobrazit rozdíly:

app/model/repository/TransliterationRepository.php
28 28
    const COLUMN_DATE = 'date';
29 29
    const COLUMN_NOTE = 'note';
30 30

  
31
    /**
32
     * Vyhledává texty podle slov v řádcích textu
33
     * @param $queryParams array podmínky pro hledaný text
34
     * @return \Nette\Database\ResultSet
35
     */
31 36
    public function transliterationsFulltextSearch($queryParams)
32 37
    {
33 38
        $where = '';
......
35 40

  
36 41
        if($queryParams['exact_match'])
37 42
        {
38
            $where .= "l.transliteration LIKE '%?%' ";
39
            $whereArgs[] = $queryParams['word1'];
43
            $where .= "l.transliteration LIKE ? ";
44
            $whereArgs[] = "%" . $queryParams['word1'] . "%";
40 45
        }
41 46
        else
42 47
        {
43
            $where .= "l.transliteration LIKE '%?%' ";
44
            $whereArgs[] = $queryParams['word1'];
48
            // padá při zadávání diakritiky?
49
            $splitWord = str_split($queryParams['word1']);
50
            $regex = implode("[\[\]⌈⌉?!><\.₁₂₃₄₅₆₇₈₉₀\-\s]*?", $splitWord);
51
            $where .= "l.transliteration REGEXP ? ";
52
            $whereArgs[] = $regex;
53
        }
54

  
55
        if($queryParams['word2_condition'])
56
        {
57
            $where .= ELogicalConditions::$whereCondition[$queryParams['word2_condition']] . " l.transliteration LIKE ? ";
58
            $whereArgs[] = "%" . $queryParams['word2'] . "%";
59
        }
60

  
61
        if($queryParams['word3_condition'])
62
        {
63
            $where .= ELogicalConditions::$whereCondition[$queryParams['word3_condition']] . " l.transliteration LIKE ? ";
64
            $whereArgs[] = "%" . $queryParams['word3'] . "%";
45 65
        }
46 66

  
47 67
        $query = "SELECT b.book_abrev, t.chapter, l.transliteration, l.line_number FROM transliteration t

Také k dispozici: Unified diff