After insert not working 24.10

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
omackeytech
Veteran Member
Posts: 35
Joined: 2014-06-04 13:18

After insert not working 24.10

Post by omackeytech » 2024-03-04 14:36

I have a database in AP that worked till 24.10 upgrade.
I run the app and when I add a new record I get this error -
Query:
INSERT INTO `Actions`(`P_Record_ID`, `Name`, `Description`, `Location`, `Context`, `Due_Date`, `Source_Table`, S_Record_ID)
SELECT `P_Record_ID`, `Name`, `Description`, `Location`, `Context`, `Due_Date`, 'Tools_Needed', ''
FROM `Tools_Needed` t
WHERE t.ID =
Notice that right after 'Tools_Needed' the field is null also after' WHERE t.ID ='. That's supposed to be the PK. I looked in the database with PHP Admin and the record doesn't exist. I use the identical code for 'after update' and it works. Of course, the record is in the database anyway using UPDATE.

To me it looks like it's not inserting the record before calling the function 'after insert'.

Any thoughts?
Or is my code wrong?

Code: Select all

	function Tools_Needed_after_insert($data, $memberInfo, &$args) {
		$myID = $data['selectedID];
		$S_Record_ID = $myID;
		$Tn = "Tools_Needed";
		If ($data['Context'] != "") {sql("INSERT INTO `Actions`(`P_Record_ID`, `Name`, `Description`, `Location`, `Context`, `Due_Date`, `Source_Table`, S_Record_ID)
			SELECT `P_Record_ID`, `Name`, `Description`, `Location`, `Context`, `Due_Date`, '$Tn', '$myID' 
			FROM `Tools_Needed` t
			WHERE t.ID = $myID", $eo);
			}
		
		return TRUE;

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1817
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: After insert not working 24.10

Post by jsetzer » 2024-03-04 14:52

Did you check for SQL errors in admin area?

Your insert statement contains a constant S_Record_ID which, as far as I can see, is undefined. I guess you mean a variable $S_Record_ID instead.

If there are no SQL errors, are you sure there are no new records in DB? Or maybe you just cannot see them in browser because you did not set_record_owner for the newly inserted records.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

omackeytech
Veteran Member
Posts: 35
Joined: 2014-06-04 13:18

Re: After insert not working 24.10

Post by omackeytech » 2024-03-04 18:53

Js,

The S_Record_ID is a column in the 'actions' table. I probably should remove the reference to '$S_Record_ID' since I stopped using it. I just use the '$myID' instead.

The admin log shows the same error. Under the string I see this "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4 " Line 4 is where I reference the 'Tools_Needed' row '$myID' (Pk).

What I'm trying to do is copy the inserted records ID to the 'actions' table so I can refer back to the 'Tools Needed' Table when the row in the actions table is deleted.

Thanks for your help.
Brian

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1817
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: After insert not working 24.10

Post by jsetzer » 2024-03-05 04:00

$myID = $data['selectedID];
There is a single quote missing.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply