From: Stéphane Jacob Date: Mon, 3 Oct 2011 09:40:17 +0000 (+0200) Subject: Improves phone prefix detection. X-Git-Tag: xorg/1.1.4~102 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=6f9358f44cc8bcbba718c52a1b3e0bb4d70d0f13;p=platal.git Improves phone prefix detection. Signed-off-by: Stéphane Jacob --- diff --git a/classes/phone.php b/classes/phone.php index 8356f64..be6f3ad 100644 --- a/classes/phone.php +++ b/classes/phone.php @@ -187,10 +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 = {?} - ORDER BY phonePrefix DESC + 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;