Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2005, 04:37 AM
Dream's Avatar
Dream Dream is offline
 
Join Date: Oct 2001
Posts: 2,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default let's see whos good at sql

im breaking my head for about two hours, need a query to get the custom templates from the "template" table. what it needs to do, is a inner join that gets all templates which names doesn't exist in the master style (styleid -1). that's what I was able to come up with :/

Code:
SELECT t1.templateid, t1.styleid, t1.title, t2.styleid, t2.title 
FROM template AS t1, template AS t2 
WHERE t1.templatetype = 'template' AND t2.templatetype = 'template' 
AND (t1.styleid <> -1 AND t1.title <> t2.title AND t2.styleid = -1) 
AND NOT (t1.styleid = -1 AND t1.title = t2.title AND t2.styleid = -1) 
GROUP BY t1.templateid, t2.title 
ORDER BY t1.title
Reply With Quote
  #2  
Old 06-22-2005, 04:44 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should look into something like:
[sql]SELECT * from template as t1
WHERE t1.title NOT IN (SELECT t2.title FROM template AS t2 WHERE t2.styleid = -1);[/sql]
This is not the complete statement, but should get you started.
Reply With Quote
  #3  
Old 06-22-2005, 10:56 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[sql]
SELECT customstyle.* FROM template AS customstyle
LEFT JOIN template AS masterstyle ON (masterstyle.title = customstyle.title AND masterstyle.styleid = -1)
WHERE ISNULL(masterstyle.templateid)
[/sql]
Reply With Quote
  #4  
Old 06-23-2005, 06:00 AM
Dream's Avatar
Dream Dream is offline
 
Join Date: Oct 2001
Posts: 2,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks kirby, gonna use that one.

im having a problem calling $db->query_read() with it now, doesnt log errors in error_log and it seems to not even try the query. do i need to initialize something to use $db?
Reply With Quote
  #5  
Old 06-23-2005, 08:29 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dream
thanks kirby, gonna use that one.

im having a problem calling $db->query_read() with it now, doesnt log errors in error_log and it seems to not even try the query. do i need to initialize something to use $db?
If you are working within vBulletin no, if you are including vBulletin's global.php file then no. Otherwise yes you would have to include the class manualy and set it up correctly.
Reply With Quote
  #6  
Old 06-23-2005, 05:17 PM
Dream's Avatar
Dream Dream is offline
 
Join Date: Oct 2001
Posts: 2,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im including global.php... its weird, I tried query_read( somefunction() ), and it doesnt even enter the other function.


edit:

BTW, anyone of you would know a query to remove all thread ratings made by the author of the thread?

Quote:
Originally Posted by Dream
im including global.php... its weird, I tried query_read( somefunction() ), and it doesnt even enter the other function.
can't call $db from inside a function, had to pass it as a variable to the function.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:46 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03677 seconds
  • Memory Usage 2,210KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete