PDA

View Full Version : Query for friends question


Boofo
Wed 30th Apr '08, 2:26am
Is there a query we can run to update the amount of friends a user has to the proper level?

Jake Bunce
Wed 30th Apr '08, 2:30am
Are you talking about the text on their profile page that says, Showing X of Y Friend(s)? That number appears to be cached in the user.friendcount field. Unfortunately I don't have a simple query to rebuild that counter, and there doesn't appear to be a utility for this in the Admin CP. Of course the count should be updated automatically once the user adds or removes a friend.

Boofo
Wed 30th Apr '08, 2:43am
Yes, that is the count I am referring to. So there in no way to fix a wrong count unless the user updates it eventually?

Jake Bunce
Wed 30th Apr '08, 2:53am
Correct. There doesn't appear to be an option for this in the Admin CP and I don't have a simple query for it.

Boofo
Wed 30th Apr '08, 3:31am
OK, well, thanks, anyway.

I think this something they need to look at if they are going to add things like this to vb. Another example of something wasted.

Jafo
Thu 24th Jul '08, 5:43pm
Here is what I did.. Use at your own risk:

<?php

define('NO_REGISTER_GLOBALS', 1);

define('THIS_SCRIPT', 'updatefriends');

require_once('./global.php');

$users = $db->query("
SELECT *
FROM " . TABLE_PREFIX . "userlist WHERE friend = 'yes'

");

while ($user = $db->fetch_array($users))
{
$useri[$user['userid']]++;
}

foreach ($useri as $key => $value) {

echo "Updating $key to $value<P>";

$db->query("update " . TABLE_PREFIX . "user set friendcount = $value where userid = $key");

}

?>