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 09-15-2005, 12:43 AM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What is wrong with this plugin query?

Code:
$db->query_write("UPDATE " . TABLE_PREFIX . "thread SET open = 0 WHERE threadid = '$threadid' AND votetotal/votenum <= '5'");
Why doesn't that work?

If I change it to:
Code:
$db->query_write("UPDATE " . TABLE_PREFIX . "thread SET open = 0 WHERE threadid = '$threadid' AND votetotal <= '5'");
It works fine...
Reply With Quote
  #2  
Old 09-15-2005, 12:57 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Because votetotal/votenum is invalid sql?
Reply With Quote
  #3  
Old 09-15-2005, 01:02 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@merk
Works just fine for me ...
Reply With Quote
  #4  
Old 09-15-2005, 01:03 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Strange.


May have been a chance in the way MySQL deals with certain syntax then? What version of MySQL flypaper / Kirby?
Reply With Quote
  #5  
Old 09-15-2005, 01:13 AM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
@merk
Works just fine for me ...
If I just run the query, by itself, it works fine. As a plugin, it doesn't work tho...

edit: And I think I'm using 4.0.25
Reply With Quote
  #6  
Old 09-15-2005, 01:15 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, depends where you run that as a Plugin (eg. which Hook).
I am using an outdated mySQL 4.1.12, but I think that doesn't matter much.
Reply With Quote
  #7  
Old 09-15-2005, 01:19 AM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oops. Im using 4.1.12 also.

And the hook is threadrate_add.
Reply With Quote
  #8  
Old 09-15-2005, 01:28 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It think the following does happen:

1) The Threadrate Datamager gets the $threadinfo array (which contains open=1)
2) You issue the Query to close the Thread
2) save() is called on the Threadrate Datamanager,
After saving, the Datamanager instantiates a Thread Datamanager to update votetotal/votenum using $threadinfo that has passed earlier (containing open=1)
Then it writes this to the Database - undoing what your query did.

Does that make sense?

I'd hook into threaddata_presave and check the rating there, if it's below your limit set open=0.
This should work, without any Query overhead.
Reply With Quote
  #9  
Old 09-15-2005, 05:23 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the error message? A bit hard to determin the problem without knowing why it "doesnt work".
Reply With Quote
  #10  
Old 09-15-2005, 06:41 PM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
It think the following does happen:

1) The Threadrate Datamager gets the $threadinfo array (which contains open=1)
2) You issue the Query to close the Thread
2) save() is called on the Threadrate Datamanager,
After saving, the Datamanager instantiates a Thread Datamanager to update votetotal/votenum using $threadinfo that has passed earlier (containing open=1)
Then it writes this to the Database - undoing what your query did.

Does that make sense?

I'd hook into threaddata_presave and check the rating there, if it's below your limit set open=0.
This should work, without any Query overhead.

Would that explain the 2nd query I gave in the original post working tho? btw, I will test this tonite for sure...
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 05:41 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.06472 seconds
  • Memory Usage 2,245KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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