vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Getting the id of a result before it's posted? (https://vborg.vbsupport.ru/showthread.php?t=115513)

DrewM 05-13-2006 10:54 PM

Getting the id of a result before it's posted?
 
I have a tutorial system set up. I have just added a feature that allows images for the tutorial to be uploaded to data base. It saves them with the tutorial id so it can repeat the image code for the tutorials using a where cause with tutorial ids. But I can't do this if the tutorial id is not posted yet. Is it possible to get the id before it's posted is my basic question.

:banana:

filburt1 05-13-2006 11:09 PM

Lock the table, find out the first available ID, insert all your stuff related to the ID, and then unlock the table. The locking is to avoid concurrent modifications and hence duplicate IDs. You won't encounter the problem unless you are making a lot of queries each second.

akanevsky 05-13-2006 11:12 PM

I suggest doing this the way vBulletin handles newpost attachments: each new post has a posthash, which serves as the temporary ID.

DrewM 05-14-2006 12:09 PM

Quote:

Originally Posted by Psionic Vision
I suggest doing this the way vBulletin handles newpost attachments: each new post has a posthash, which serves as the temporary ID.

How could I do this? Would you just have it do random numbers like session?

akanevsky 05-14-2006 12:12 PM

Yes. You generate a hash when you first access the new post page, then you pass the hash on via $_POST data. When you insert data into other tables, insert it without specifying id, but with specifying the hash. Then, when you actually save the whole post, update the entries by removing the hash and inserting the real id.

DrewM 05-14-2006 12:14 PM

Quote:

Originally Posted by Psionic Vision
Yes. You generate a hash when you first access the new post page, then you pass the hash on via $_POST data. When you insert data into other tables, insert it without specifying id, but with specifying the hash. Then, when you actually save the whole post, update the entries by removing the hash and inserting the real id.

thanks


All times are GMT. The time now is 03:55 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.01629 seconds
  • Memory Usage 1,716KB
  • 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_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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