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

 Inserting sequential records

Print topic Send  topic

Author Message
Per Jansson
Posted: 02/07/2003, 3:56 PM

I am using CodeCharge Studio beta 2, mysql and php and need help on the code for inserting several records with one click.

Until now I have been able to work around the updating of extra tables by adding an extra page and the extra record for the action.

What I would like to achieve is that when I insert (or update) record, is to immediately after change a different record, sometimes in a different table and sometimes in the same table but a different row.

This should be done with an After Insert/Update event I have understood. From all the other questions on this matter I have not been able to figure how to do it.
In this explicit case below I would like to update one item in a table when a new row is inserted. In this case this is the same table for both actions. The event becomes After Insert
My database connection is called "linguamorgana", my table "flow" and the item to be updated is called "completed". Completed is an enum with y and n as values. It needs to be changed from n to y. Conditions for the WHERE clause for the update are table item "taskorder" which has to be 0 (zero) and a passed parameter called news_id. I don't know how to catch a passed parameter in the custom code.

$db->query("UPDATE flow SET completed='y' WHERE taskorder='0' AND news_id=???");

Can somebody tell me what is wrong with this code and also explain these two issues:
Would $db need to be called $linguamorgana or $dblinguamorgana?
What would be needed in order to use the passed parameter news_id?


I would be very grateful for help on this issue, as I have several other situations where I would like to implement sequences of updating.

Per Jansson
Per Jansson
Posted: 02/08/2003, 2:03 AM

This issue has been resolved.
Per J
yodabear
Posted: 02/09/2003, 2:38 AM

Per, could you please post your solution
Per Jansson
Posted: 02/09/2003, 3:18 AM

Ok,
Here is the solution I have used.
My situation was the following:

My database connection is called "linguamorgana", my table "flow" and the item to be updated is called "completed". Completed is an enum with y and n as values. It needs to be changed from n to y. Conditions for the WHERE clause for the update are table item "taskorder" which has to be 0 (zero) and a passed parameter called news_id. I don't know how to catch a passed parameter in the custom code.

In the the After Insert custom code I had to type this:

// First define the variables to use in the code,
global $DBlinguamorgana; // linguamorgana is the name of the data base connection
global $news_id_param; // this is the name of the parameter I want to catch and use

// Second catch the parameter, I catch from post as my record just inserted it.
$news_id_param = CCGetFromPost("news_id","");

// Create the SQL statement to be executed
$DBlinguamorgana->query("UPDATE flow SET new='n' WHERE taskorder='0' AND news_id='$news_id_param'");

I am a beginner and don't really know on which level to make an explanation on this. If you need further help or discussion on what is going on mail me atper@lepelle.com

Per
Per Jansson
Posted: 02/09/2003, 3:27 AM

Error in the code.

the name "completed" was "new" in the SQL I just posted.
Per

   


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.