PDA

View Full Version : Help with DB query for postbit.


tinycg
07-29-2007, 10:41 AM
I'm attempting to add my members Xbox Live Gamerscore as pulled by the gXboxlive mod which stores the gamerscore in the gboxlive.score table with the userid the same as user.userid.

So this was my thinking:
$gmscore = $db->query("SELECT " . TABLE_PREFIX . "gxboxlive.*, " . TABLE_PREFIX . "gxboxlive.score AS score, FROM " . TABLE_PREFIX . "gxboxlive WHERE " . TABLE_PREFIX . "gxboxlive.userid = " . $vbulletin->userinfo['userid'] . " LIMIT 1");
$player = $db->fetch_array ($gmscore);

I realize now that by looking at some other things that $vbulletin->userinfo['userid']

Is bringing up the logged in user and not the post's userid, so that's part of the problem, does anyone know the right way I should be querying this in vB?

I've been up late on this, but could use some help with it, I'm naive with vb's code, but am trying to produce a query to pull the score based on the userid, then add it to the postbit with $player[score]

I had the query seemingly working with an odd join based on the gboxlive code but it still wasn't printing the score out in the template.

Dismounted
07-29-2007, 10:47 AM
Use $post['userid'] instead. Although you should really query all the scores and cache them, preventing 1 query for each post displayed on the page.

tinycg
07-29-2007, 10:57 AM
Forgive me Dismounted but what would be the best way to go about doing that, or is there even a way to tie a userfield to a database table and just call the userfield??

testebr
08-01-2007, 11:22 AM
how to make cache of query?

Dismounted
08-02-2007, 06:31 AM
Query the whole lot, put them into an array. Then you can simply access that array to access the data,

Adrian Schneider
08-02-2007, 06:48 AM
You can actually just do a join in the main posts query to get that data.