This topic is locked
[SOLVED]

 Help Request - Update Detail Records When Master Record Updated

9/18/2020 6:50:46 PM
PHPRunner General questions
O
OzCPA author

I have extensively edited my original post as my explanation of the problem may have made it seem more complex than it is. I am not a programmer, but to someone familiar with PHPRunner, it should almost be a trivial task that I am hoping someone can help me with.
I have setup a simple database consisting of two tables (i.e. Clients and Notes). The Clients table is linked in a “one-to-many” relationship to the Notes table by way of the "clientcode" field in each table.
My database allows for (say) a Client = Jones to be setup and then have multiple Notes records added over time.
What I am trying to achieve is when I set a "flag" in a Clients record to (say) "1", ALL of its "child" records in the Notes table also have a flag set to "1". That way, I can setup a query which shows ONLY those records (in both the Clients table and the Notes table) where the flag is not = "1". It effectively behaves like a "cascade delete" without actually doing the delete ... but from a user perspective, those records are no longer visible.
I hope that someone can assist me as I have spent many hours experimenting without any luck (as I have NO programming experience whatsoever).
Many thanks in advance.

fhumanes 9/20/2020

Hello:
The first thing to try is to have a normalized data model. In this case, I see that you have not done it and that is why you have the need to do this operation.
If you have done it consciously, this also occurs, you should insert a PHP code in the "After Record Updates" event.
If you do not know enough PHP to write this code, you have no choice but to access the many resources on the internet to read an initial one (with that and PHPRunner, you will be able to do many things). That will give you ease to solve this case and many more.
Greetings,
fernando

O
OzCPA author 9/21/2020



Hello:
The first thing to try is to have a normalized data model. In this case, I see that you have not done it and that is why you have the need to do this operation.
If you have done it consciously, this also occurs, you should insert a PHP code in the "After Record Updates" event.
If you do not know enough PHP to write this code, you have no choice but to access the many resources on the internet to read an initial one (with that and PHPRunner, you will be able to do many things). That will give you ease to solve this case and many more.
Greetings,
fernando


Thanks for your response ... it is much appreciated. However, I think that my question may not have be worded well originally, so I have updated my question completely. I only want to use PHPRunner to create simple databases, and I am able to do that easily with PHPRunner. However, the ONLY thing that I still need to do is to hide "related" records in both the Master and Details table by way of a "flag"; and that I cannot do because I am not a programmer. I don't want to invest massive amounts of time in learning PHP etc because I only need to solve the single problem that I have outlined in my reworded post.

Sergey Kornilov admin 9/22/2020

If you need the exact code you either need to learn a bit of coding or to hire someone. Not to mention that you can contact support directly.
If you prefer to do this on your own here are some links.
Most likely you will need to use AfterEdit event of the master record:

https://xlinesoft.com/phprunner/docs/after_record_updated.htm
And to update data in the database you can use Database API:

https://xlinesoft.com/phprunner/docs/db_update.htm

The syntax is fairly straightforward.

O
OzCPA author 9/23/2020



If you need the exact code you either need to learn a bit of coding or to hire someone. Not to mention that you can contact support directly.
If you prefer to do this on your own here are some links.
Most likely you will need to use AfterEdit event of the master record:

https://xlinesoft.com/phprunner/docs/after_record_updated.htm
And to update data in the database you can use Database API:

https://xlinesoft.com/phprunner/docs/db_update.htm

The syntax is fairly straightforward.


Thanks for that