]> git.openstreetmap.org Git - nominatim.git/blob - lib/Status.php
small typos and wording in the API docs
[nominatim.git] / lib / Status.php
1 <?php
2
3 namespace Nominatim;
4
5 use Exception;
6 use PEAR;
7
8 class Status
9 {
10     protected $oDB;
11
12     public function __construct(&$oDB)
13     {
14         $this->oDB =& $oDB;
15     }
16
17     public function status()
18     {
19         if (!$this->oDB || PEAR::isError($this->oDB)) {
20             throw new Exception('No database', 700);
21         }
22
23         $sStandardWord = $this->oDB->getOne("SELECT make_standard_name('a')");
24         if (PEAR::isError($sStandardWord)) {
25             throw new Exception('Module failed', 701);
26         }
27
28         if ($sStandardWord != 'a') {
29             throw new Exception('Module call failed', 702);
30         }
31
32         $sSQL = 'SELECT word_id, word_token, word, class, type, country_code, ';
33         $sSQL .= "operator, search_name_count FROM word WHERE word_token IN (' a')";
34         $iWordID = $this->oDB->getOne($sSQL);
35         if (PEAR::isError($iWordID)) {
36             throw new Exception('Query failed', 703);
37         }
38         if (!$iWordID) {
39             throw new Exception('No value', 704);
40         }
41     }
42
43     public function dataDate()
44     {
45         $sSQL = 'SELECT EXTRACT(EPOCH FROM lastimportdate) FROM import_status LIMIT 1';
46         $iDataDateEpoch = $this->oDB->getOne($sSQL);
47
48         if (PEAR::isError($iDataDateEpoch)) {
49             throw Exception('Data date query failed '.$iDataDateEpoch->getMessage(), 705);
50         }
51
52         return $iDataDateEpoch;
53     }
54 }