vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   user.userid explained (https://vborg.vbsupport.ru/showthread.php?t=36963)

TECK 04-04-2002 01:20 AM

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 [high]post.*,post.username[/high] and not only * ?
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?

Zzed 04-04-2002 04:43 AM

It seems reduntant. There are no fields that are being selected from user.

Admin 04-04-2002 05:19 AM

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.

Zzed 04-04-2002 06:12 AM

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? ;)

Admin 04-04-2002 06:19 AM

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.

TECK 04-04-2002 07:41 AM

firefly, you guessed right about the shortened version.
your explanation answer my questions. thank you.


All times are GMT. The time now is 07:05 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00988 seconds
  • Memory Usage 1,716KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete