This topic is locked

BeforeAdd - can't add record in another table

5/13/2008 10:24:36 AM
PHPRunner General questions
I
Isterklister author

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=8467&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' /><img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=8467&image=2&table=forumtopics' class='bbc_emoticon' alt=':)' />

Hello,

I have two tables (simplified for this question):

  • Rapp_Rigg (ID, Name, Comment)
  • Rapp_Comment (ID, Text)
    When I create a new record in Rapp_Rigg I will store the Comment in Rapp_Comment (and the Rapp_Comment (ID) in Rapp_Rigg (Comment)).

    I will use BeforeAdd for this I think but I can't get anything to be inserted in Rapp_Comment. I have read several topics in this forum but I probably are doing something really wrong.
    Can someone help me - please?
    /Pelle

A
alang 5/13/2008

Typically it is not good practice to store the same information in multiple places. From your description you appear to want to be able to store multiple comments in Rapp_Comment relating to one record in Rapp_Rigg. In this case you need to use a master-detail relationship between the two tables and so the "Comment" field in Rapp_Rigg will then be a foreign key into the the Rapp_Comment table. In its simplest form, this can be implemented in PHPR without writing any special event code at all - set up initially on the "Datasource tables" tab.

J
Jane 5/14/2008

Pelle,
please post your event code here.

R
rockrockers23 5/15/2008

try to post your code buddy...
if you did not encounter any errors : THIS MAYBE THE PROBLEM...:

Maybe you forgotten to include the code : return true; on your BeforeAdd EVENT codes

I
Isterklister author 5/16/2008

"return tru" - I have definitly forgotten that.

I have to look on that. I will be back on that.
I'm sorry if I explained my problem bad.

What I'm trying to do is to have comments stored in a separate table - but only maximum one comment for each record in Rapp_Rigg.

The reason why I will have the comments in a separate table is because in most cases I will not have a comment and then I save some space (not much but I will practice this solution in other more spaceconsuming system later).