Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
What is the proper way to Foreign Key?
  • Posted: 13.05.2006, 22:54
     
    rank:
    Freshman Freshman
    registered:
     February 2006
    Status:
    offline
    last visit:
    15.09.06
    Posts:
    28
    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.
  • Posted: 18.05.2006, 04:30
     
    rank:
    Freshman Freshman
    registered:
     February 2006
    Status:
    offline
    last visit:
    15.09.06
    Posts:
    28
    Wow ... no one cares to reply?
  • Posted: 18.05.2006, 16:12
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    How about a simple JOIN SQL ?

    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org
  • Posted: 19.05.2006, 23:03
     
    rank:
    Freshman Freshman
    registered:
     February 2006
    Status:
    offline
    last visit:
    15.09.06
    Posts:
    28
    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.
  • Posted: 20.05.2006, 18:41
     
    Chestnut
    rank:
    Steering Committee Steering Committee
    registered:
     August 2002
    Status:
    offline
    last visit:
    03.03.08
    Posts:
    1221
    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



    --
    Chestnut !
    Support via Private message won't be answered...
    http://dev.pnconcept.com
    http://www.postnuke-france.org

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula