The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
SQL Query Acting Weird
It is weird, because I can call $username342342342342 just fine from a template, but if I change Code:
$userinfo31221213 = fetch_userinfo($Entries['Date']); Code:
$userinfo31221213 = fetch_userinfo($Entries['Author']); |
#2
|
||||
|
||||
You should really perform a LEFT JOIN on the user table instead of a nested fetch_userinfo() call.
Why would you use $Entries['Date'] ... shouldn't it be $Entries['Author']. Also, I'm surprised your query even executes because 'Date' is a reserved MySQL keyword. Add this debug code to the end of your loop PHP Code:
|
#3
|
|||
|
|||
Quote:
It should be Author, but for some reason it would only work if it was the last column in the table. How do I do a LEFT JOIN? |
#4
|
|||
|
|||
[sql] SELECT contestv.ID, contestv.Contest, contestv.Author, contestv.Location, contestv.Date, user.*
FROM " . TABLE_PREFIX ."contestview AS contestv LEFT JOIN " . TABLE_PREFIX ."user AS user ON(user.username = contestv.Author) WHERE contestv.ID = " . intval($contestID) . " [/sql] That is the gist of a LEFT JOIN... Some other things: You should really use userid if you are currently using username...it is easier to index and better for normalization. And column name are simpler to remember if all are lowercase IMO. |
#5
|
|||
|
|||
Ah, thank you.
|
#6
|
|||
|
|||
Hm, I don't get it...
Code:
$queryMe = "SELECT contestv.ID, contestv.Contest, contestv.Author, contestv.Location, contestv.TheDate, user.* FROM " . TABLE_PREFIX . "contestview AS contestv LEFT JOIN " . TABLE_PREFIX . TABLE_PREFIX . "user AS user ON(user.username = contestv.Author) WHERE contestv.Contest = " . intval($contestID); $Entry = $db->query_read($queryMe); while ($Entries = $db->fetch_array($Entry) ) { eval('$contestEntries .= "' . fetch_template('contestview_bit') . '";'); } It freezes my internet browser. Also Author is a userid. |
#7
|
|||
|
|||
You are concatenating TABLE_PREFIX twice to the user table, and if Author is a userid, you need to join on user.userid not user.username
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|