Page 1 of 1

Child table not appearing

Posted: 2025-06-13 21:56
by andrewlaw
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.

Re: Child table not appearing

Posted: 2025-06-14 03:14
by jsetzer
Did you set_record_owner('TABLENAME', $newPrimaryKey, $memberID) after manually inserting data?

Re: Child table not appearing

Posted: 2025-06-16 19:53
by andrewlaw
No, I did not. Is the new primary key returned from sql or is there another call I need to make to get that?

Re: Child table not appearing

Posted: 2025-06-16 23:01
by jsetzer

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

Re: Child table not appearing

Posted: 2025-06-17 15:02
by andrewlaw
Thank you! I ended up using the insert function though it's not documented in the AppGini PHP functions reference.