Using stored procedure in a hook

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
ojoerk
Posts: 2
Joined: 2022-12-06 14:34

Using stored procedure in a hook

Post by ojoerk » 2023-02-27 14:36

Hello,
I created a stored procedure in MariaDB, which works well. Now I wanted to use it in the table_after_insert() hook. I could imagine to do it like this:

$db->query('call insertMaintenance('.$data['ResourceId'].', '.$data['EndDate'].');');

But where does this $db object comes from? Do I have to create a new one or is there still one available from the previous insert operation?
Thank you for pointing me to the right direction.

Olaf

ojoerk
Posts: 2
Joined: 2022-12-06 14:34

Re: Using stored procedure in a hook

Post by ojoerk » 2023-02-27 17:01

I found the sql()function and tried:

sql("call insertMaintenance('".$data['ResourceId']."', '".$data['EndDate']."')", $error);

But then I'm getting an "out of sync" error. Nevertheless, the data was inserted to the database. How can I avoid this error?

angus
Veteran Member
Posts: 128
Joined: 2020-05-28 22:27

Re: Using stored procedure in a hook

Post by angus » 2023-03-15 22:43

maybe try

Code: Select all

sql("call insertMaintenance('".$data['ResourceId']."', '".$data['EndDate']."')", $o);
AppGini 22.13

Post Reply