vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Combine 2 parts of mysql, how? (https://vborg.vbsupport.ru/showthread.php?t=52381)

Dark Jim 04-30-2003 07:07 PM

Combine 2 parts of mysql, how?
 
I have this query in privatemessage.php:
PHP Code:

  $messages $DB_site->query("SELECT
  privatemessage.*,
  IF(ISNULL(touser.username),'[Deleted User]',touser.username) AS tousername,
  IF(ISNULL(fromuser.username),'[Deleted User]',fromuser.username) AS fromusername,
  icon.title AS icontitle,icon.iconpath
  "
.iif($iconavatarenabled,",iconavatar.iconavatarpath,NOT ISNULL(customiconavatar.iconavatardata) AS hascustomiconavatar,customiconavatar.dateline AS iconavatardateline","")."
  FROM privatemessage
  LEFT JOIN icon ON icon.iconid=privatemessage.iconid
  LEFT JOIN user AS touser ON (touser.userid=privatemessage.touserid)
  LEFT JOIN user AS fromuser ON (fromuser.userid=privatemessage.fromuserid)
  "
.iif($iconavatarenabled && privatemessage.userid!=privatemessage.touserid,"LEFT JOIN iconavatar ON iconavatar.iconavatarid=touser.iconavatarid LEFT JOIN customiconavatar ON customiconavatar.userid=touser.userid","")."
  WHERE privatemessage.userid='
$bbuserinfo[userid]'
  AND folderid='"
.intval($folderid)."'
  
$ignoreusers
  
$dateconds
  ORDER BY dateline DESC"
); 

This part:
PHP Code:

  ".iif($iconavatarenabled && privatemessage.userid!=privatemessage.touserid,"LEFT JOIN iconavatar ON iconavatar.iconavatarid=touser.iconavatarid LEFT JOIN customiconavatar ON customiconavatar.userid=touser.userid","")." 

needs to somehow combined with:
PHP Code:

  ".iif($iconavatarenabled && privatemessage.userid!=privatemessage.fromuserid,"LEFT JOIN iconavatar ON iconavatar.iconavatarid=fromuser.iconavatarid LEFT JOIN customiconavatar ON customiconavatar.userid=fromuser.userid","")." 

How would I do that? I tried a few things and nothing worked. Seaching for "iif" on php.net and mysql.com didn't work. :(

filburt1 04-30-2003 08:02 PM

iif is in functions.php and is identical to the construct:
PHP Code:

$something iif($condition$truevalue$falsevalue);
// same as:
$something = ($condition $truevalue $falsevalue); 

Theoretically, though, the second one is slightly faster.


All times are GMT. The time now is 11:21 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.01856 seconds
  • Memory Usage 1,721KB
  • 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
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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