This topic is locked
[SOLVED]

 To update master and details tables

11/16/2012 2:53:24 PM
PHPRunner General questions
S
sancarlosantioquia author

Hello
I need your help with the follow problem i am using the Template Cars and have problems for update the details records, i need that if the master field is changed the childs records update with the new name example.
Table carsmake

Id

make
Table carsmodels

id

make

model
I am using this code for to do the change but not work i am using in details recodrs not work and from master table and not work
global $dal;

$tblDetail = $dal->Table("carsmodels");

$tblDetail->Value["make"] = $values["make"];

$tblDetail->Param["make"] = $values["make"];

$tblDetail->Update();

unset($values["make"]);
Please i need your help is urgent
to i am using this code but not work
global $conn;

$sql = "update carsmodels set make=".$values["make"]." ... ";

db_exec($sql,$conn);

unset($values["make"]);
Please some that can help me
Thanks

C
cgphp 11/17/2012

Where did you add the code above? Please, tell us in which event has been added.

What is the foreign key of the details table?

S
sancarlosantioquia author 11/17/2012



Where did you add the code above? Please, tell us in which event has been added.

What is the foreign key of the details table?


Hello thanks for answer me
I am using both events
Before record added

and
After record updated
Foreign key details table is make
Thanks

Sergey Kornilov admin 11/19/2012

Okay, as far as I understand you need to update make field in carsmodels table when make field in carsmake changes.
Use the following code in carsmake BeforeEdit event:
CustomQuery("update carsmodels set make='".$values["make"]."' where make='".$oldvalues["make"]."'");

S
sancarlosantioquia author 11/20/2012



Okay, as far as I understand you need to update make field in carsmodels table when make field in carsmake changes.
Use the following code in carsmake BeforeEdit event:
CustomQuery("update carsmodels set make='".$values["make"]."' where make='".$oldvalues["make"]."'");


Very good Work perfectly

Thank for your help