CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 Update two tables in DB at the same time

Print topic Send  topic

Author Message
RipCurl
Posted: 04/11/2003, 3:22 PM



Im in need of trying to figure out how to update two tables (records) in my database from one record form.

I've checked the tips and articles section for it, and came across one by Alex, but the "db" provided is not for MySql so I can't run it or figure out what he is accomplising in the provided cc project file (since i can't see his DB structure)

Im modifying the bug tracking example to include " solutions " for the bug that is being addressed.

i have two tables, bugs and responses that will need to be updated/inserted into at the same time.

In the form called solution (record form), the employee can respond with their "solution" and change the status, priority and reassign the bug to someone else. I also have a "date updated" field that is autmatically inserted when they submit their response.

So upon submitting,
the table in the db will get the inserted response
but
I want to have the bug table updated with the new info from the response form
(if priority was changed, status, reassigned to another employee, and add the date_updated)

Can someone provide an example for PHP + Templates and MySql or explain where I need to insert some code into the "solution" form to do this using CC 2.0.5 (not CCS)
RipCurl
Posted: 04/11/2003, 3:51 PM



Okay, I got the status, employee, priority and responses inserts and updates to work ,but Im having problem with the date_updated field.

in both Bugs and in Responses tables in the DB, i have a field called date_updated in DATETIME format handled by MYSQL

in the Solutions form, i have in the the BEFORE SHOW INSERT event:

$flddate_updated=date("Y-m-d h:i:s"); so it obtains the correct MYSQL format

So when the form is displayed in the text box, the field shows the current date and time.


In the AFTER INSERT Event i have this:

$sWhere2 = "bug_id = $fldbug_id";
$sSQL2 = "update bugs set " .
"priority_id=" . tosql($fldpriority_id, "Number") .
",status_id=" . tosql($fldstatus_id, "Number") .
",assigned_to=" . tosql($fldassigned_to, "Number") .
",date_updated=" . tosql($flddate_updated, "Number");
$sSQL2 .= " where " . $sWhere2;

$db->query($sSQL2);

So priority, status, assigned_to all get updated in the bugs record form but the date_updated gets updated with 2000-20-03 00:00:00 for some reason.

How can I make sure it takes the correct date_updated time from the form and posts it to the bugs record correctly? It posts to the responses table correctly (ie showing hte correct time and date).

Ripcurl
Posted: 04/11/2003, 4:01 PM

Damn, my bad, i had "Number" instead of "Date" for the updqte in the AFTER INSERT event for that field.

kay, problem solved....it works how i needed it.

   


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

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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