CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Multiple tables in a single form

Print topic Send  topic

Author Message
cabrera

Posts: 10
Posted: 01/20/2009, 9:49 AM

I need to prepare a form that updates multiple tables at the same time, sort of a transaction kind of process, ideally with a commit and rollback on it.

I know the CodeCharge tool provides an easy way to update one table at a time, but I haven't been able to figure out how to have several of them updated with the same form. Has anybody done this before?

If so, let me know how you did it, thanks!
View profile  Send private message
sosamv

Posts: 50
Posted: 01/20/2009, 10:51 AM

Hi there man! if you want to be able to rollback a transaction you will probably need to use a stored procedure. As for the other question, is pretty simple, each record form has a lot of events methods, you can use the "After insert" to add custom code and manually insert info on other tables (If you need the code i'ii post it on request), I posted a snippet days ago that explains how to get the last_inserted id, check it out will be useful.

jerry

View profile  Send private message
cabrera

Posts: 10
Posted: 01/20/2009, 11:46 AM

Thanks Jerry,

If you can post your code or send the link to your last post that will be great.

There seems to be some documentation around for the after insert event, but it always help to see how other people implement it.

We though about store procedures, but we were trying to save development time by using the tool to do as much for us as possible before we did any extra code, I guess if we want multi-table forms there is no automatic way of doing it.

One question, if we use the "After Insert" event, we could probably put the extra sql there, but does the after event means at least one table has been modified already once the user post? Meaning, if we get error responses in the after event sql code and we need to rollback, we would have to roll back manually the first form insertion that happens before the after insert event?
View profile  Send private message
jjrjr1


Posts: 942
Posted: 01/20/2009, 11:58 AM

Hi.

In CCS here is probably the best way to get the last inserted ID.

This way you will always get the ID for the form that is being inserted positively.

$LastID = mysql_insert_id($Container->DataSource->Link_ID);

This should be in the after insert event for the form.

Also it needs to be in each form on your page as echh form will have it's own event processing. (This is one reason it might be difficult to do multi form posts at the PHP side)

I personally have never tried a submit for multiple forms on on one page.

Like sosamv suggested, there are many events you can look at. However, for multiple forms I suspect you might look at the client side events. Maybe you need to do the multi submits in the HTML.

Have Fun.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
cabrera

Posts: 10
Posted: 01/20/2009, 1:44 PM

Makes sense, I was just looking at the concatenation of forms example at:

http://examples.codecharge.com/ExamplePack/MultiStepReg...d.php?user_id=3

and it looks way easier than trying to do everything in one page. I'll probably do it that way.

Thanks guys
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.