Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-03-2014, 09:29 AM
Randomguyy Randomguyy is offline
 
Join Date: Sep 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Where in the code are new threads created?

Hello VBulletin forum,

I am trying to have VBulletin make an additional database entry when creating a new thread. But I just can't seem to find the section where this happens.

Could anyone give me some directions?
Reply With Quote
  #2  
Old 12-04-2014, 02:27 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

All the posts go through the API -- vB_Api_Content_{Text, Photo, Link, Poll}

From there, it's handed off to the library (vB_Library_Content_}, and then it gets handed down to the db classes (vB_dB_MySQL_*).

IIRC, all a "new thread" is is a post whose parent is the containing channel.
Reply With Quote
  #3  
Old 12-04-2014, 09:37 AM
Randomguyy Randomguyy is offline
 
Join Date: Sep 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright, that helped a lot. Thanks for the quick reply!
Reply With Quote
  #4  
Old 12-15-2014, 09:27 AM
Randomguyy Randomguyy is offline
 
Join Date: Sep 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I'll need some more help.

I want to make the database entry with this line of code (maybe this is already where I'm doing a mistake?):

Code:
$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "my_table (field1, field2, field3) VALUES (1, 2, 3)");

Now I want this line to be executed upon creating a new thread. So I went and inserted it in the vb_api_content_text add() function, and after it not working I also tried vb_library_content_text add() and a whole lot of other possible functions elsewhere.

However, not once did it actually do a database entry and I would always get this error message from VB in my browser:

Error while saving content: SyntaxError: Unexpected token F

Maybe noteworthy is that while it gave that error message and didn't redirect me to the newly created topic, it did create it nonetheless.


Can you (or someone else) tell what I'm doing wrong? :\
Reply With Quote
  #5  
Old 12-18-2014, 02:50 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could it be an error with your SQL? Without seeing actual code and/or data, it's tough to debug.

Additionally, the db->query_write stuff is depreciated. Not sure if it'll actually be removed from the source code or not...but might be a good idea to look at the DB Assertor classes. If, for no better reason than it's the vb5 way.
Reply With Quote
  #6  
Old 02-09-2015, 12:26 PM
Randomguyy Randomguyy is offline
 
Join Date: Sep 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So I finally had the opportunity to actually continue working on this and first of all, thanks for your reply.

As you suggested, I took a look at the DB Assertor classes and used the insert() function instead of query_write() and changed my code accordingly:

Code:
vB_dB_Assertor::insert("my_table", array("field1" => 1, "field2" => 1, "field3" => 1));
I believe this should be correct, but feel free to correct my syntax in case I did something wrong.

Anyway, on to my problem.

I put this in the add() function of vb_api_content (also tried other functions of other classes), but still to no avail. I don't get any error messages anymore, but at the same time nothing happens. So either I'm in the wrong spot or my code is wrong.

Any ideas? :\
Reply With Quote
  #7  
Old 02-11-2015, 02:18 AM
Dead Eddie's Avatar
Dead Eddie Dead Eddie is offline
 
Join Date: Apr 2004
Location: at Home...
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you need to have an entry in the DB Assertor class for your table. You should be able to create your own DB Assertor class and do the entire thing without file edits, though.
Reply With Quote
Благодарность от:
Randomguyy
  #8  
Old 02-11-2015, 02:22 PM
Randomguyy Randomguyy is offline
 
Join Date: Sep 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works like a charm now. Thanks a lot for your help!
Reply With Quote
  #9  
Old 03-31-2015, 10:26 AM
Randomguyy Randomguyy is offline
 
Join Date: Sep 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So making db entries when creating a new topic works for me. Now, though, I have a new problem.

What I want to do is make it possible to basically reply to a topic with another topic. To do this, I created a button in a PHP module in the first topic, which also adds the topic's ID in the URL. I want to save the IDs of the first and second topic in the db so that I can connect both via a link in f.e. a PHP module.

Now I want this to happen right as you click the 'Post' button for creating a new topic. However, for the life of me, I can't find where exactly in the code I would have to add my own code to execute the db insert.

help pls?
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 07:34 AM.


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.06175 seconds
  • Memory Usage 2,246KB
  • 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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (1)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete