CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 PHP/mySQL - MultiTable Updates - HALF WAY THERE...

Print topic Send  topic

Author Message
Chip Cotton
Posted: 07/06/2002, 12:42 PM

I just wanted to post my progress in dealing with a 1-1 2 table form.

The one table is just the headers, the 2nd table has a link field and
a longtext field for the 'body' of the page.

PLEASE LET ME KNOW IF THERE'S AN EASIER WAY OF DOING WHAT I'M DOING!

So far, I have a select and an update working, the next will be an
insert and then delete.

A record form contains the 'headers' and an unbound memo field.

notes:
la= table long_articles
lab=table long_articles_bodies

1st: Select / display in the form's 'before show' event:

//SELECT STATEMENT
global $long_articles_frm;
global $DBConnection1;
$la_id = CCGetParam("la_id", "");
$this_sql = "select lab_body from long_articles_bodies where lab_id =
'". $la_id . "'";
$long_articles_frm->lab_body->setvalue(CCGetDBValue($this_sql,$DBConnection1));


2nd: Update code in "after update" event of form.
//UPDATE STATEMENT
global $long_articles_frm;
global $DBConnection1;
$la_id = CCGetParam("la_id", "");
$lab = addslashes(CCGetParam("lab_body", "")); //note addslashes.
$this_sql = "update long_articles_bodies set lab_body = '". $lab ."'
where lab_id = '". $la_id . "'";
$DBConnection1->query($this_sql);

I'll post the insert's and delete's when I get them done, but it seems
the above is a solid template for what is to follow...
Chip Cotton
Posted: 07/08/2002, 11:42 AM

To follow up on the previous message, this is how I did it with CCS.

Question: I couldn't get the "ToSQL" function to work. Could someone
give an example? I assume that you could/should use it instead of the
PHP 'addslashes' function (although I would suspect the "ToSQL"
function uses it...

The one table is just the headers of the long articles, the 2nd table
has a link field and a longtext field for the 'body' of the page.

A record form contains the 'headers' and an unbound memo field.

note:
la = table long_articles
lab = table long_articles_bodies

//BEFORE SHOW EVENT OF UNBOUND LABEL
global $long_articles_frm;
global $DBConnection1;
$la_id = CCGetParam("la_id", "");
$this_sql = "select lab_body from long_articles_bodies where lab_id =
'". $la_id . "'";
$long_articles_frm->lab_body->setvalue(CCGetDBValue($this_sql,$DBConnection1));


//AFTER UPDATE EVENT OF RECORD FORM
global $long_articles_frm;
global $DBConnection1;
$la_id = CCGetParam("la_id", "");
$lab = addslashes(CCGetParam("lab_body", ""));
$this_sql = "update long_articles_bodies set lab_body = '". $lab ."'
where lab_id = '". $la_id . "'";
$DBConnection1->query($this_sql);

//AFTER INSERT EVENT OF RECORD FORM
global $long_articles_frm;
global $DBConnection1;
$last_id = mysql_insert_id();
//echo 'last insert id = ' . $last_id;
$sSQL2 = "insert into long_articles_bodies (" .
"lab_id," .
"lab_body)" .
" values (" .
$last_id . ",'" .
addslashes($long_articles_frm->lab_body->getvalue()) .
"')";
$DBConnection1->query($sSQL2);

//AFTER DELETE EVENT OF RECORD FORM
global $long_articles_frm;
global $DBConnection1;
$la_id = CCGetParam("la_id", "");
$this_sql = "DELETE FROM long_articles_bodies WHERE lab_id = '".
$la_id . "'";
$DBConnection1->query($this_sql);

   


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

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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