This topic is locked

Master -Detail Edit / Delete Info

3/30/2011 9:12:25 AM
PHPRunner General questions
cyberjas2001 author

I wanna find a way to alter / delete information on a table named "Company" which has some "Users" related. "Company" is my master table and "Users" is my details, because when i changed something on my Company table the Users table keep the same information. I wanna have the ability to erase the company table and take all the records related with it.

Is there any easy way to do it?

Thanks

P
pvdemael 3/30/2011

You should use events for this like the Before record deleted event in the list page.

There you have access to the key which links it to the details table.
You can build a delete query with this key value and execute it on the relevant tables.

cyberjas2001 author 3/30/2011

I tried this code on the Edit Page: After Record Updated. Master table is "company", detail table is "driver":
global $dal;

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

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

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

$tblDetail->Update();

unset($values["Company"]);
But nothing seems to changed...

cyberjas2001 author 3/31/2011

Any help with this????

J
Jane 4/1/2011

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

cyberjas2001 author 4/1/2011

Is something really simple, when you alter any information on the Master table Company should change the information on Details table Driver as well, for example:

Master Table "Company"

Name: ABC Company
Details Table "Driver"

Company Name: ABC Company
I have this code in the event Company Edit Page:After Record Updated



global $dal;

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

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

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

$tblDetail->Update();

unset($values["Company"]);


So when I update the information on Company "ABC Company" as "XYZ Company", the drivers should be affected as well, but it doesn't.

Sergey Kornilov admin 4/1/2011

How do you want us to help?

cyberjas2001 author 4/1/2011

I know that something is wrong in my code and that's why is not updating the new values on the details table, can you guide me a little bit?

Sergey Kornilov admin 4/1/2011

The only way to troubleshoot this code is to get access to the application.

N
nti 4/9/2011



I wanna have the ability to erase the company table and take all the records related with it. Is there any easy way to do it?


  1. How to delete TABLE "Company" and delete TABLE "Users"? Suggestion: Utilize innoDB engines and setup relationships. Delete Cascade for TABLE "Users"


    "Company" which has some "Users" related. "Company" is my master table and "Users" is my details, because when i changed something on my Company table the Users table keep the same information. Is there any easy way to do it?


2. Suggestion: Detail TABLE FIELD for "Company Name Field" utilizes TABLE "Company" and the "Company id field" and Display Field = "TABLE "Company" and "Company Name field"

P
pvdemael 4/11/2011



  1. How to delete TABLE "Company" and delete TABLE "Users"? Suggestion: Utilize innoDB engines and setup relationships. Delete Cascade for TABLE "Users"
  2. Suggestion: Detail TABLE FIELD for "Company Name Field" utilizes TABLE "Company" and the "Company id field" and Display Field = "TABLE "Company" and "Company Name field"


Both suggestions are the best solutions.

Never use strings which can change to refer to other tables. The use of ID fields (integers) are the best way to go.

cyberjas2001 author 5/3/2011

1 Suggestion, Im looking into it, thanks

2 Suggestion, sounds interesting, but how can i apply that using my info? im a little bit confused.




  1. How to delete TABLE "Company" and delete TABLE "Users"? Suggestion: Utilize innoDB engines and setup relationships. Delete Cascade for TABLE "Users"
  2. Suggestion: Detail TABLE FIELD for "Company Name Field" utilizes TABLE "Company" and the "Company id field" and Display Field = "TABLE "Company" and "Company Name field"