The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
user.userid explained
can you help me understand the mechanism of this query?
Code:
$posts=$DB_site->query(" SELECT post.*,post.username AS postusername FROM post LEFT JOIN user ON user.userid=post.userid LEFT JOIN userfield ON userfield.userid=[high]user.userid[/high] WHERE $postids ORDER BY dateline $postorder "); why is it present the [high]user.[/high] part? what is the difference between user.userid and post.userid? why i see all the time this kind of code structure (user.userid) in vB? |
#2
|
||||
|
||||
It seems reduntant. There are no fields that are being selected from user.
|
#3
|
||||
|
||||
Actually Zzed I think nakkid posted a shortened version of the showthread.php query.
tblName.fldName is called qualification. It's used when you select data from multiple tables, although it's only required if you have the same field in both tables (specifying the table name so it knows from which table to select the field). If you don't do this you will get an ambiguousness error. |
#4
|
||||
|
||||
Given what nakkid posted it seemed redundant. But within the context of showthread.php it makes perfect sense. How else would you populate the user information without selecting from user.* in order to show the posts?
|
#5
|
||||
|
||||
Oh, nakkid, re why post.username AS postusername and not just post.*:
For guests we want to show what they entered in the form, so choosing user.username would override post.username, and since user.username is empty (not registered) we won't have a username at all. |
#6
|
||||
|
||||
firefly, you guessed right about the shortened version.
your explanation answer my questions. thank you. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|