$j = 0; while ($item = $it->next()) { $phone = new Phone($item); $phone->delete(); $phone->save(); ++$i; ++$j; if ($j == 100) { $j = 0; printf("\r%u / %u", $i, $total); } } printf("\r%u / %u", $i, $total); print "\nFormating done.\n\n"; print "Deletes duplicated phones. (4/4)\n"; $pids = XDB::rawFetchColumn("SELECT DISTINCT(pid)\n FROM profile_phones AS p1\n WHERE link_type = 'user' AND EXISTS (SELECT *\n FROM profile_phones AS p2\n WHERE p2.link_type = 'user' AND p2.pid = p1.pid AND p2.tel_id != p1.tel_id)\n ORDER BY pid"); $total = count($pids); $done = 0; $aux = 0; $deleted = 0; $phones = array(); $duplicates = array(); foreach ($pids as $pid) { $count = 0; $it = Phone::iterate(array($pid), array(Phone::LINK_PROFILE), array(0), Visibility::get(Visibility::VIEW_PRIVATE)); while ($item = $it->next()) { $phones[] = $item; ++$count; } for ($i = 0; $i < $count; ++$i) { for ($j = $i + 1; $j < $count; ++$j) {
private function getPIDList($pids = null, PlLimit $limit) { $this->requireProfiles(); $this->buildQuery(); $lim = $limit->getSql(); $cond = ''; if (!is_null($pids)) { $cond = XDB::format(' AND p.pid IN {?}', $pids); } $fetched = XDB::rawFetchColumn('SELECT SQL_CALC_FOUND_ROWS p.pid ' . $this->query . $cond . ' GROUP BY p.pid ' . $this->orderby . ' ' . $lim); $this->lastprofilecount = (int) XDB::fetchOneCell('SELECT FOUND_ROWS()'); return $fetched; }