Fork me on GitHub

What is the proper way to Foreign Key?  Bottom

  • Greetings, I am writing a module that needs the user's id from the pnuser table. I would like to create a foreign key for my tables but I would need to know the proper way to get the pnuser table name that accounts for changes in table prefix and so on. Essentially I need the pntables result for the user module. How do I get that ?

    I would look it up on the API reference but that seems to have VANISHED! :(

    TIA.
  • Wow ... no one cares to reply?
  • How about a simple JOIN SQL ?
  • I could do that but then the prefix of the table and table name is hardcoded and that is bad. There should be some way to get thoese names from the API.
  • In 762... using

    Code

    $pntable = pnDBGetTables();


    Will get you the user table information

    Code

    $usertbl = $pntable['users'];
    $usercol = $pntable['users_column'];


    In 0.8, you'll need a

    Code

    pnModDBInfoLoad('Users');


    The users table will then be available the same way.

    As you said, having your table name hardcoded is bad, if you are building a module, you should have a pntables.php.

    icon_wink

This list is based on users active over the last 60 minutes.