vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   What is wrong with this plugin query? (https://vborg.vbsupport.ru/showthread.php?t=96285)

fly 09-15-2005 12:43 AM

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...

merk 09-15-2005 12:57 AM

Because votetotal/votenum is invalid sql?

Andreas 09-15-2005 01:02 AM

@merk
Works just fine for me ...

merk 09-15-2005 01:03 AM

Strange.


May have been a chance in the way MySQL deals with certain syntax then? What version of MySQL flypaper / Kirby?

fly 09-15-2005 01:13 AM

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

Andreas 09-15-2005 01:15 AM

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.

fly 09-15-2005 01:19 AM

oops. Im using 4.1.12 also.

And the hook is threadrate_add.

Andreas 09-15-2005 01:28 AM

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.

merk 09-15-2005 05:23 AM

What is the error message? A bit hard to determin the problem without knowing why it "doesnt work".

fly 09-15-2005 06:41 PM

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...


All times are GMT. The time now is 05:19 PM.

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.01174 seconds
  • Memory Usage 1,734KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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