Child table not appearing

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
andrewlaw
Posts: 24
Joined: 2025-06-11 09:22
Contact:

Child table not appearing

Post by andrewlaw » 2025-06-13 21:56

I have two tables, and article and article_status table. The article_status table has four fields in addition to the primary key.

When the article table is inserted, I run this code in the article_after_insert:

Code: Select all

        $sql = "INSERT INTO article_status (article_id, status, user, created, notes) VALUES (".$data['selectedID'].", 'Draft', '".$memberInfo['username']."', NOW(), 'Initial Entry')";
        sql($sql, $eo);
The correct values are entered into the article_status table.

However, the status does not appear in the child table on the article detail view. I can add another status through the web interface and it will appear but the one I inserted with code never does.

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

Re: Child table not appearing

Post by jsetzer » 2025-06-14 03:14

Did you set_record_owner('TABLENAME', $newPrimaryKey, $memberID) after manually inserting data?
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 25.10 + all AppGini Helper tools

andrewlaw
Posts: 24
Joined: 2025-06-11 09:22
Contact:

Re: Child table not appearing

Post by andrewlaw » 2025-06-16 19:53

No, I did not. Is the new primary key returned from sql or is there another call I need to make to get that?

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

Re: Child table not appearing

Post by jsetzer » 2025-06-16 23:01

Code: Select all

$pk = db_insert_id(db_link())
Tip: there is a very useful insert() function which takes TABLENAME and a data array


AppGini PHP functions reference.
https://share.google/Oer1HRpsadtyBQpPS
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 25.10 + all AppGini Helper tools

andrewlaw
Posts: 24
Joined: 2025-06-11 09:22
Contact:

Re: Child table not appearing

Post by andrewlaw » 2025-06-17 15:02

Thank you! I ended up using the insert function though it's not documented in the AppGini PHP functions reference.

Post Reply