problems with product registration

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi everyone,

     I have the following problem: i have 3 pages: Page1, Page2,
Page3; These pages register a product.
In Page1 i do a post to Page2. In Page2, i asynchrony upload some
images, to be used at Page2 itself, the images will be saved at the
DB, and used like: <img src=3D"ShowImage.php?cod=3D1231">. Each Image     has
a product associated.
   If the user that will register his product, at Page2 already has
done 3 images upload, and close the web browser, what will happen? The
database will have the uploaded images, but these images will not have
a product associated, cause the user had not done the last post at
   I=B4ve beeing doing a research, and i realized that i could use a
transaction. But, this transaction needs a persisten connection.
   I use postgresql, Did anyone knows how to solve my problem? How Can
i use a persistent connection with php? Did the persistent connection
will solve my problem?

   Thanks very much

Re: problems with product registration

xaviergxf wrote:
Quoted text here. Click to load it

Persistent connections won't help you here, either.  The transaction
will still be terminated at the end of your second page.

What you need to do is store the data somewhere temporarily, i.e. in
another table, then remember the key to the row.  Also add a timestamp
column to tell when the data was inserted.

If the complete Page 3, fetch the data you just stored and place it in
your live tables, then delete it.  Then, on a regular basis (i.e. once a
day), go through your temporary storage table and remove anything > 24
hours (via a cron job), based on the timestamp you placed in the row.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: problems with product registration

Quoted text here. Click to load it

As you're not sure how slow your users can be (upload something, go drink  
a cup of coffee, come back, and only then continue), I'd say go for the  
easy route: let them sit there for a certain period of time you and your  
users deem reasonably safe to assume the action is aborted, and clean your  
database up with a cron job that looks for either orphan images with a  
timestamp longer then X time ago.

Alternatively, you could use a database driven session, in which case the  
garbage handler would take over the job mentioned for the cronjob earlier:  
as soon as you think a session is timed out, the garbage collector can  
delete the sessiondata and related images. Of course, loading all data of  
the images in $_SESSION is not the way to go, so either store them in in  
other BLOB columns of a related row if they have a fixed amount, or in a  
related table, and use a foreign key delete cascade.
Rik Wasmus
[SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work to  
fund a self developed bigger project, mail me at rik at [/SPAM]

Site Timeline