예제 #1
0
 static function getCityId($city)
 {
     $sql = self::$db->quote(lingua::getKeywords($city));
     $sql = "SELECT city_id\n                FROM city\n                WHERE search={$sql}\n                LIMIT 1";
     $sql = self::$db->query($sql)->fetchAll(PDO::FETCH_NUM);
     return $sql ? $sql[0][0] : 0;
 }
예제 #2
0
 protected static function initAccents()
 {
     self::$ACCENT_FROM = array("/[\\p{Mn}\\p{Lm}]/u", '/[ÆǼǢ]/u', '/[æǽǣ]/u', '/ß/u', '/Œ/u', '/œ/u', '/[ʤʣʥ]/u', '/ff/u', '/ffi/u', '/ffl/u', '/fi/u', '/fl/u', '/ƕ/u', '/Ƣ/u', '/ƣ/u', '/[stſt]/u', '/ʨ/u', '/ʦ/u', '/ƻ/u');
     self::$ACCENT_TO = array('', 'AE', 'ae', 'ss', 'OE', 'oe', 'dz', 'ff', 'ffi', 'ffl', 'fi', 'fl', 'hv', 'OI', 'oi', 'st', 'tc', 'ts', '2');
     $len = self::$ACCENT_LENGTH = count(self::$ACCENT);
     for ($i = 0; $i < $len; ++$i) {
         $v = self::$ACCENT[$i];
         self::$ACCENT_FROM[] = '/[' . substr($v, 1) . ']/u';
         self::$ACCENT_TO[] = $v[0];
     }
 }
예제 #3
0
 function compose($o)
 {
     $db = patchworkPath('data/geodb.sqlite3');
     $db = new PDO("sqlite:{$db}");
     $sql = $this->get->q;
     $sql = '*' == $sql ? '' : lingua::getKeywords($sql);
     $sql = substr($db->quote($sql), 1, -1);
     switch ($a = substr($sql, 0, 3)) {
         case 'agi':
         case 'ayi':
             if ('os ' == substr($sql, 3, 3)) {
                 $sql = substr($sql, 5);
                 $sql = "search GLOB 'agios{$sql}*' OR search GLOB 'ayios{$sql}*'";
                 break;
             }
         case 'st ':
             $sql = 'saint ' . substr($sql, 3);
         default:
             $sql = '' === $sql ? 1 : "search GLOB '{$sql}*'";
     }
     $sql = "SELECT city_id, city FROM city WHERE {$sql} ORDER BY rowid";
     $o->cities = new loop_city_($db, $sql, 15);
     return $o;
 }
예제 #4
0
 static function php($str, $case = 0)
 {
     return lingua::stripAccents($str, $case);
 }