vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Autocreate new thread .... BUT .... !! (https://vborg.vbsupport.ru/showthread.php?t=73444)

cinq 12-29-2004 01:59 AM

Autocreate new thread .... BUT .... !!
 
I am coding a hack which auto creates a new thread in a specified forum.
However, how could I get hold of the threadid after it has been created ?
Any ideas ?

Basically, creation of the thread is solved, but i would need to threadid, in order to say delete or modify that entry.

Any help pls ? :)

cinq 12-29-2004 12:05 PM

Hmm, poked around a bit, and this turned up.

PHP Code:

$thread['threadid'] = $DB_site->insert_id(); 

Will this do the trick ?

Xenon 12-29-2004 04:49 PM

nope ;)

that's why build_new_post get's a reference to the $post array, so after you have used build_new_post the threadid is stored in $post['threadid'] already :)

rake 12-29-2004 09:18 PM

actually Xenon, you are wrong. after running the insert query, insert_id() will return the threadid of the newly created thread. So, yes cinq, you are right about that.

Michael Morris 12-29-2004 09:34 PM

It's much easier to put the post information for the new thread into a $post array and call the existing build_new_post function. Once it completes, it will put the thread id of the newly created thread into threadinfo['threadid']. There's no need to run another query.

rake 12-29-2004 09:43 PM

it doesn't run another query. :)

cinq 12-29-2004 11:25 PM

Erm .... now I'm confused .... :p
So what's the 'verdict' ?

rake 12-30-2004 01:12 PM

if you want to insert the new thread "manually" by writing the query yourself, you can get the threadid by using the insert_id() function. Using insert_id will not count as another query.

or, you can use the build_new_post function.

cinq 12-30-2004 01:16 PM

Yep, I write the query myself.
So insert_id() it is then :)

Thanks rake, thanks everyone :D

Xenon 01-01-2005 02:34 PM

erm rake, you are wrong here.

build_new_post runs two queries when creating a new thread, one for the post and one for the thread.

as the post query is executed after the thread query the insert_id will give you the postid but not the threadid :)


All times are GMT. The time now is 08:57 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.03012 seconds
  • Memory Usage 1,723KB
  • 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
  • (1)bbcode_php_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