From 6f9358f44cc8bcbba718c52a1b3e0bb4d70d0f13 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 3 Oct 2011 11:40:17 +0200 Subject: [PATCH] Improves phone prefix detection. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- classes/phone.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; -- 2.1.4