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