View Full Version : 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 ? :)
Hmm, poked around a bit, and this turned up.
$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 :)
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.
it doesn't run another query. :)
Erm .... now I'm confused .... :p
So what's the 'verdict' ?
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.
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 :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.