X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fphone.php;h=be6f3ad80fbd432795e44739f2ddd42d0fefb454;hb=e8ecbab4ad48a3c8c262c91bb492312be3738f86;hp=c70928157e12d06ba3dd5d242f928ccf3708b743;hpb=ddfe523d631a70b9256e50010a35acbcc19e72a6;p=platal.git diff --git a/classes/phone.php b/classes/phone.php index c709281..be6f3ad 100644 --- a/classes/phone.php +++ b/classes/phone.php @@ -187,9 +187,10 @@ class Phone if ((!isset($format['phoneprf'])) || ($format['phoneprf'] == '')) { $res = XDB::query('SELECT phonePrefix AS phoneprf, phoneFormat AS format FROM geoloc_countries - WHERE phonePrefix = {?} OR phonePrefix = {?} OR phonePrefix = {?} + WHERE phonePrefix = SUBSTRING({?}, 1, LENGTH(phonePrefix)) + ORDER BY LENGTH(phonePrefix) DESC LIMIT 1', - substr($tel, 0, 1), substr($tel, 0, 2), substr($tel, 0, 3)); + $tel); if ($res->numRows() == 0) { // No country found, does not format more than prepending a '+' sign. $this->error = true;