![]() |
Tandy 8/13/2025 |
On the table you are editng in the After record updated: $data = array(); Hope that helps.. |
B
|
bioman author 8/13/2025 |
Thanks Tandy, $data = array(); It seems basically the same as Method 3 (which didn't work either), but with $data replacing $fieldValues. It seems like the code is correct for both of these but nothing happens to the details. Are there other things besides the code itself that might cause these failures? For example, my project is connected to 2 databases, but gamenames and partygames are in the same database, so it doesn't seem like this should matter. Or is something missing in the code? Any further insight would be great. Thanks, |
![]() |
Tandy 8/13/2025 |
That code worked for mine. Was hoping that it would work for you. You are using case sensitive right? It is in After Record Updated as well right? Then in mine I do not have return true. Here is mine. I have it in my fuel(After Record Updated) and need to update my Mileage in Truck Profile: //Update Mileage in truck_profile - begin |
![]() |
Tandy 8/13/2025 |
Here is another one taking my ending milage of my trip report and updating my mileage on my Truck Lube. Both tables have the same Key Values of the Truck Number. Not going for the ID. Again this is listed in my Trip Report under After Record Updated and still no return True; //Update Mileage in truck_lube - begin |
B
|
bioman author 8/14/2025 |
Thanks, // In the After record Updated event for the master table 'gamenames' // Define the new values to update in the details table 'partygames' This didn't work but I'm wondering if maybe this is on the right track... Is the syntax still wrong? |
C
|
cristi 8/14/2025 |
Instead of doing this in PHP I strongly advise to use a foreign key constraint in the database. |
B
|
bioman author 8/14/2025 |
Hi Cristi, |
C
|
cristi 8/15/2025 |
https://youtu.be/oT4YWW_sbNQ?feature=shared Be aware that foreign key constraints are supported ONLY on InnoDB for both MySQL and its most popular fork MariaDB. |
B
|
bioman author 8/16/2025 |
Hi Cristi, |
B
|
bioman author 8/17/2025 |
Ok, I used the following code (with help from Gemini) to check what is happening at the database: // Define the new values to update in the details table 'partygames' // 1. Build the SET part of the query // 2. Build the WHERE part of the query // 3. Assemble the final SQL statement // 4. Display the query and stop the script // --- END: SQL DEBUGGING CODE --- // Your original code (the script won't run this part because of exit()) I then did the following:
It gave me the following results: UPDATE Affected rows: 6 This shows that the SQL query works and affected the 6 rows it should have affected. This does NOT work however, when I build and test my PHPRunner project. There doesn't appear to be anything wrong with the code, but it doesn't work. Is this just a bug in PHPRunner 11 or is something else going on? Any ideas would be great! Thanks! |
C
|
Chris Whitehead 8/19/2025 |
I am wondering if you have any unique indexes in the child table? then when updating the records this tries to produces a duplicate, then mysql doesn't allow the update query to work by any method. I can't see anything wrong in the query as you've tried multiple methods to update the child records. I'd stick with method 3 in phprunner. If you turn on the debug mode this should show the queries When you echo the query which is produced, grab this query and try it in something like HeidiSql so it's running directly in the database, this will show you the error if any. |
B
|
bioman author 8/20/2025 |
Hi Chris, |
C
|
Chris Whitehead 8/24/2025 |
It could also be that you might be trying to update a record which doesn't exist with that ID in the partygames table. these are the steps I'd take to debug the issue, forgive me if you've tried these. Turn on debug mode in after initialise application event Then check if there's a record in the after update record. // just to show the data in the $values array and check if id exists in the array If the record does exist, then move the exit to after the update record block, this ensures the queries aren't cleared, once you have the sql query, use this in something like HeidiSql to ensure it runs or it will tell you any error. // Define the new values to update in the details table 'partygames' |