XDB::formatArray -> XDB::format().
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 6 Mar 2010 18:22:41 +0000 (19:22 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 6 Mar 2010 18:22:41 +0000 (19:22 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/profile.php
classes/userfilter.php
core

index f83f5f1..47ebdac 100644 (file)
@@ -260,7 +260,7 @@ class Profile
     {
         $cond = '';
         if ($this->visibility) {
-            $cond = ' AND pub IN ' . XDB::formatArray($this->visibility);
+            $cond = XDB::format(' AND pub IN {?}', $this->visibility);
         }
         $res = XDB::query("SELECT  *
                              FROM  profile_photos
@@ -290,7 +290,7 @@ class Profile
             $where .= ' AND FIND_IN_SET(\'mail\', pa.flags)';
         }
         if ($this->visibility) {
-            $where .= ' AND pa.pub IN ' . XDB::formatArray($this->visibility);
+            $where .= XDB::format(' AND pa.pub IN {?}', $this->visibility);
         }
         $type = array();
         if ($flags & self::ADDRESS_PRO) {
@@ -300,7 +300,7 @@ class Profile
             $type[] = 'home';
         }
         if (count($type) > 0) {
-            $where .= ' AND pa.type IN ' . XDB::formatArray($type);
+            $where .= XDB::format(' AND pa.type IN {?}', $type);
         }
         $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
         return XDB::iterator('SELECT  pa.text, pa.postalCode, pa.type, pa.latitude, pa.longitude,
@@ -379,7 +379,7 @@ class Profile
             $where .= ' AND pn.network_type = 0'; // XXX hardcoded reference to web site index
         }
         if ($this->visibility) {
-            $where .= ' AND pn.pub IN ' . XDB::formatArray($this->visibility);
+            $where .= XDB::format(' AND pn.pub IN {?}', $this->visibility);
         }
         $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
         return XDB::iterator('SELECT  pne.name, pne.icon,
@@ -411,8 +411,8 @@ class Profile
         $where = XDB::format('pj.pid = {?}', $this->id());
         $cond  = 'TRUE';
         if ($this->visibility) {
-            $where .= ' AND pj.pub IN ' . XDB::formatArray($this->visibility);
-            $cond  =  'pj.email_pub IN ' . XDB::formatArray($this->visibility);
+            $where .= XDB::format(' AND pj.pub IN {?}', $this->visibility);
+            $cond  = XDB::format('pj.email_pub IN {?}', $this->visibility);
         }
         $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
         return XDB::iterator('SELECT  pje.name, pje.acronym, pje.url, pje.email, pje.NAF_code,
@@ -510,9 +510,9 @@ class Profile
                            LEFT JOIN  profile_phones AS pp ON (pp.pid = p.pid AND pp.link_type = \'user\' AND tel_type = \'mobile\')
                            LEFT JOIN  profile_photos AS ph ON (ph.pid = p.pid)
                            LEFT JOIN  account_profiles AS ap ON (ap.pid = p.pid AND FIND_IN_SET(\'owner\', ap.perms))
-                               WHERE  p.pid IN ' . XDB::formatArray($pids) . '
+                               WHERE  p.pid IN {?}
                             GROUP BY  p.pid
-                                   ' . $order);
+                                   ' . $order, $pids);
     }
 
     public static function getPID($login)
@@ -543,8 +543,8 @@ class Profile
         return XDB::fetchAllAssoc('uid', 'SELECT  ap.uid, ap.pid
                                             FROM  account_profiles AS ap
                                            WHERE  FIND_IN_SET(\'owner\', ap.perms)
-                                                  AND ap.uid IN ' . XDB::formatArray($uids) .'
-                                               ' . $order);
+                                                  AND ap.uid IN {?}
+                                               ' . $order, $uids);
     }
 
     /** Return the profile associated with the given login.
index b6c2dd1..ff446a3 100644 (file)
@@ -70,7 +70,7 @@ class UFC_Hruid implements UserFilterCondition
     public function buildCondition(PlFilter &$uf)
     {
         $ufc->requireAccounts();
-        return 'a.hruid IN ' . XDB::formatArray($this->hruids);
+        return XDB::format('a.hruid IN {?}', $this->hruids);
     }
 }
 // }}}
@@ -94,7 +94,7 @@ class UFC_Hrpid implements UserFilterCondition
     public function buildCondition(PlFilter &$uf)
     {
         $uf->requireProfiles();
-        return 'p.hrpid IN ' . XDB::formatArray($this->hrpids);
+        return XDB::format('p.hrpid IN {?}', $this->hrpids);
     }
 }
 // }}}
@@ -237,7 +237,7 @@ class UFC_EducationSchool implements UserFilterCondition
     public function buildCondition(PlFilter &$uf)
     {
         $sub = $uf->addEducationFilter();
-        return 'pe' . $sub . '.eduid IN ' . XDB::formatArray($this->val);
+        return XDB::format('pe' . $sub . '.eduid IN {?}', $this->val);
     }
 }
 // }}}
@@ -258,7 +258,7 @@ class UFC_EducationDegree implements UserFilterCondition
     public function buildCondition(PlFilter &$uf)
     {
         $sub = $uf->addEducationFilter();
-        return 'pee' . $sub . '.degreeid IN ' . XDB::formatArray($this->val);
+        return XDB::format('pee' . $sub . '.degreeid IN {?}', $this->val);
     }
 }
 // }}}
@@ -279,7 +279,7 @@ class UFC_EducationField implements UserFilterCondition
     public function buildCondition(PlFilter &$uf)
     {
         $sub = $uf->addEducationFilter();
-        return 'pee' . $sub . '.fieldid IN ' . XDB::formatArray($this->val);
+        return XDB::format('pee' . $sub . '.fieldid IN {?}', $this->val);
     }
 }
 // }}}
@@ -368,9 +368,9 @@ class UFC_NameTokens implements UserFilterCondition
         $sub = $uf->addNameTokensFilter(!($this->exact || $this->soundex));
         $conds = array();
         if ($this->soundex) {
-            $conds[] = $sub . '.soundex IN ' . XDB::formatArray($this->tokens);
+            $conds[] = XDB::format($sub . '.soundex IN {?}', $this->tokens);
         } else if ($this->exact) {
-            $conds[] = $sub . '.token IN ' . XDB::formatArray($this->tokens);
+            $conds[] = XDB::format($sub . '.token IN {?}', $this->tokens);
         } else {
             $tokconds = array();
             foreach ($this->tokens as $token) {
@@ -380,7 +380,7 @@ class UFC_NameTokens implements UserFilterCondition
         }
 
         if ($this->flags != null) {
-            $conds[] = $sub . '.flags IN ' . XDB::formatArray($this->flags);
+            $conds[] = XDB::format($sub . '.flags IN {?}', $this->flags);
         }
 
         return implode(' AND ', $conds);
@@ -596,7 +596,7 @@ class UFC_Binet implements UserFilterCondition
     public function buildCondition(PlFilter &$uf)
     {
         $sub = $uf->addBinetsFilter();
-        return $sub . '.binet_id IN ' . XDB::formatArray($this->val);
+        return XDB::format($sub . '.binet_id IN {?}', $this->val);
     }
 }
 // }}}
@@ -658,7 +658,7 @@ class UFC_Email implements UserFilterCondition
 
         if (count($foreign) > 0) {
             $sub = $uf->addEmailRedirectFilter($foreign);
-            $cond[] = 'e' . $sub . '.email IS NOT NULL OR a.email IN ' . XDB::formatArray($foreign);
+            $cond[] = XDB::format('e' . $sub . '.email IS NOT NULL OR a.email IN {?}', $foreign);
         }
         if (count($virtual) > 0) {
             $sub = $uf->addVirtualEmailFilter($virtual);
@@ -730,7 +730,7 @@ abstract class UFC_Address implements UserFilterCondition
             }
         }
         if (count($types)) {
-            $conds[] = $sub . '.type IN ' . XDB::formatArray($types);
+            $conds[] = XDB::foramt($sub . '.type IN {?}', $types);
         }
 
         if ($this->flags != self::FLAG_ANY) {
@@ -857,7 +857,7 @@ class UFC_AddressField extends UFC_Address
         default:
             Platal::page()->killError('Invalid address field type: ' . $this->fieldtype);
         }
-        $conds[] = $sub . '.' . $field . ' IN ' . XDB::formatArray($this->val);
+        $conds[] = XDB::format($sub . '.' . $field . ' IN {?}', $this->val);
 
         return implode(' AND ', $conds);
     }
@@ -1258,7 +1258,7 @@ class UFC_WatchRegistration extends UFC_UserRelated
         if (count($uids) == 0) {
             return PlFilterCondition::COND_FALSE;
         } else {
-            return '$UID IN ' . XDB::formatArray($uids);
+            return XDB::format('$UID IN {?}', $uids);
         }
     }
 }
@@ -1286,7 +1286,7 @@ class UFC_WatchPromo extends UFC_UserRelated
         } else {
             $sube = $uf->addEducationFilter(true, $this->grade);
             $field = 'pe' . $sube . '.' . UserFilter::promoYear($this->grade);
-            return $field . ' IN ' . XDB::formatArray($promos);
+            return XDB::format($field . ' IN {?}', $promos);
         }
     }
 }
@@ -1602,7 +1602,7 @@ class UserFilter extends PlFilter
         $lim = $limit->getSql();
         $cond = '';
         if (!is_null($uids)) {
-            $cond = ' AND a.uid IN ' . XDB::formatArray($uids);
+            $cond = XDB::format(' AND a.uid IN {?}', $uids);
         }
         $fetched = XDB::fetchColumn('SELECT SQL_CALC_FOUND_ROWS  a.uid
                                     ' . $this->query . $cond . '
@@ -1620,7 +1620,7 @@ class UserFilter extends PlFilter
         $lim = $limit->getSql();
         $cond = '';
         if (!is_null($pids)) {
-            $cond = ' AND p.pid IN ' . XDB::formatArray($pids);
+            $cond = XDB::format(' AND p.pid IN {?}', $pids);
         }
         $fetched = XDB::fetchColumn('SELECT  SQL_CALC_FOUND_ROWS  p.pid
                                     ' . $this->query . $cond . '
@@ -2207,7 +2207,8 @@ class UserFilter extends PlFilter
                 if (!is_array($key)) {
                     $key = array($key);
                 }
-                $joins['e' . $sub] = PlSqlJoin::left('emails', '$ME.uid = $UID AND $ME.flags != \'filter\' AND $ME.email IN ' . XDB::formatArray($key));
+                $joins['e' . $sub] = PlSqlJoin::left('emails', '$ME.uid = $UID AND $ME.flags != \'filter\' 
+                                                               AND $ME.email IN {?}' . $key);
             }
         }
         foreach ($this->al as $sub=>$key) {
@@ -2221,7 +2222,8 @@ class UserFilter extends PlFilter
                 if (!is_array($key)) {
                     $key = array($key);
                 }
-                $joins['al' . $sub] = PlSqlJoin::left('aliases', '$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND $ME.alias IN ' . XDB::formatArray($key));
+                $joins['al' . $sub] = PlSqlJoin::left('aliases', '$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\') 
+                                                                  AND $ME.alias IN {?}', $key);
             }
         }
         foreach ($this->ve as $sub=>$key) {
@@ -2231,7 +2233,7 @@ class UserFilter extends PlFilter
                 if (!is_array($key)) {
                     $key = array($key);
                 }
-                $joins['v' . $sub] = PlSqlJoin::left('virtual', '$ME.type = \'user\' AND $ME.alias IN ' . XDB::formatArray($key));
+                $joins['v' . $sub] = PlSqlJoin::left('virtual', '$ME.type = \'user\' AND $ME.alias IN {?}', $key);
             }
             $joins['vr' . $sub] = PlSqlJoin::left('virtual_redirect',
                                                   '$ME.vid = v' . $sub . '.vid
diff --git a/core b/core
index ae3effc..e677bc1 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit ae3effcca10c409aef7a111cc778b9dca10561b9
+Subproject commit e677bc13379b7ad58b161411ce35ba4a13bc54d3