vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Auto-creation of threads? (https://vborg.vbsupport.ru/showthread.php?t=61030)

Andreas 02-08-2004 01:02 AM

$DB_site->insert_id() gives you the id generated by the last mySQL INSERT statement (if inserting into a table with an auto-increment column like postid, threadid, etc.).

But you don't need that (see my previous post) if you are using vB functions to create threads/posts - only if you are manually dealing with the database.

> But I can only use $post['threadid'] and $post['postid'] after the build_new_post is hit in the code, correct?
Yes, that's correct.

Wired1 02-08-2004 01:03 AM

So would this part of the code I edited in to that last post work?
PHP Code:

// build the thread 
build_new_post('thread'$foruminfo, array(), 0$post$errors); 

// Errors? 
if (sizeof($errors) > 0) { 
  
// error processing 

ThreadID $post['threadid']; 
PostID $post['postid']; 


ThreadID and PostID are columns in a table I have created.

Andreas 02-08-2004 01:06 AM

Not really, as there are $-signs missing before ThreadID and PostID and thus it won't compile ;)
But the concept is right.

I don't know what you want to do with your table but you could call

PHP Code:

$DB_site->query("INSERT INTO yourtbl (ThreadID,PostID) VALUES ($post[threadid]$post[postid])"); 

to get the IDs into your table. Or make an update or whatever you want to to with the values.

Wired1 02-08-2004 01:09 AM

Lol yeah. Conceptually it's kewl. That definitely just solved like 5 potential SNAFUs! Trying to think if there were any other questions I had... (re-reading the thread quickly)...

Wired1 02-08-2004 01:16 AM

Ok, this is a minor one. If you look at the original post that started this thread, it has the title of the thread within the top of the post. I know that with proper use of templates an postbit this can be removed, but is there a way to prevent it from getting into the DB at all?

Also, with
PHP Code:

$DB_site->query("INSERT INTO yourtbl (ThreadID,PostID) VALUES ($post[threadid]$post[postid])"); 

$post[postid] is supposed to be $post['postid'] (quotes) correct? Also, $DB_site->query is just vB's way of doing $result = mysql_query($sql, $connection); right?

Also, what do you guys think about this comment I made earlier:

I'm also looking into how to auto create a forum/sub forum, but for security reasons, I think I might not let the bot have this access, and find out how to do it with normal mySQL statements (or $DB_site->query now that you've shown me its wonders)

M1th 02-08-2004 01:21 AM

Wow... this is almost the thing I need too!!

Er.. I want to create a thread automatically when a member reaches xth number of posts. I want to be able to exclude some forums from their post counts (that i know how to do). What I'm having trouble with is the actual conditional for this and also WHERE to put the code (which php file).

appreciate any help. :)

Wired1 02-08-2004 01:26 AM

That might boil down to a cron job, as they could hit that number at any time. There might be a way though for the vB admin system to PM or email you when members hit x # of posts, and you create it manually. then again, if it can notify u, it can make a thread :)

This will turn into one kickass tutorial for others! Much props goes to you all!

Andreas 02-08-2004 01:28 AM

> but is there a way to prevent it from getting into the DB at all?
AFAIK not. This would require a modification of build_new_post().

> $post[postid] is supposed to be $post['postid'] (quotes) correct?
You can ommit the quotes.

> Also, $DB_site->query is just vB's way of doing $result = mysql_query($sql, $connection); right?
Yes. vB uses a class (DB_sql_vb) the wraps mysql_ functions and thus makes database-handling easier.

M1th 02-08-2004 01:34 AM

Quote:

Originally Posted by Wired1
That might boil down to a cron job, as they could hit that number at any time. There might be a way though for it to PM or email you when members hit x # of posts, and you creat it manually. then again, if it can notify u, it can make a thread :)

This will turn into one kickass tutorial for others! Much props goes to you all!

Ah, thats a good way too, though, im not sure how that differs from creating a new thread/post?



Hmm, what I was thinking is, a way to do a check on members post count after they've done a new post. So the code has to go kinda after all that. Question is, where is the best place to put such a code.

Wired1 02-08-2004 01:34 AM

>> $post[postid] is supposed to be $post['postid'] (quotes) correct?
>You can ommit the quotes.

Everywhere, or just within $DB_site->query?

> Hmm, what I was thinking is, a way to do a check on members post count after
> they've done a new post. So the code has to go kinda after their own post sql > query or new post function. Question is, where is the best place to put such a
> code.

oooohhhh I get it now. Hrm... I suppose you'd slap that into the build_new_post function, or right after a call to that function. beats me where the best place would be though.


All times are GMT. The time now is 05:39 AM.

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.01082 seconds
  • Memory Usage 1,750KB
  • 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
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete