1 : <?php
2 :
3 : /**
4 : * Dictionaries of Old French and Latin
5 : *
6 : * PHP 5
7 : *
8 : * @category Application
9 : * @package DicFro
10 : * @author Michel Corne <mcorne@yahoo.com>
11 : * @copyright 2008-2010 Michel Corne
12 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
13 : * @link http://www.micmap.org/dicfro
14 : */
15 :
16 : require_once 'Model/Query.php';
17 :
18 : /**
19 : * Queries the Tobler database
20 : *
21 : * @category Application
22 : * @package DicFro
23 : * @author Michel Corne <mcorne@yahoo.com>
24 : * @copyright 2008-2010 Michel Corne
25 : * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
26 : */
27 :
28 : class Model_Query_Tobler extends Model_Query
29 : {
30 : /**
31 : * Constructor
32 : *
33 : * @param string $directory the dictionaries directory
34 : * @return void
35 : */
36 : public function __construct($directory = '.')
37 : {
38 4 : parent::__construct($directory . '/tobler');
39 4 : }
40 :
41 : /**
42 : * Searches a word form
43 : *
44 : * @param string $word the word form to search
45 : * @return array the list of words matching that form
46 : */
47 : public function searchWords($word)
48 : {
49 4 : $ascii = $this->string->utf8toASCII($word);
50 :
51 4 : $query = "SELECT DISTINCT main, variants, pof, lemma FROM word, entry ";
52 4 : $query .= "WHERE ascii = :ascii AND entry.line = word.line ";
53 4 : $query .= "ORDER BY main, variants, lemma, pof";
54 :
55 4 : $result = $this->execute($query, array(':ascii' => $ascii));
56 :
57 4 : return $result;
58 : }
|