This topic is locked

Linking tables Help !

8/2/2007 11:23:17 AM
PHPRunner General questions
C
chaz author

hey there i am still trying to solve this problems lol
i have 3 tables

  1. accounts: acct login password
  2. characters: acct guid
  3. characters_items: ownerguid
    As you can guess
    accounts.acct = characters.acct

    characters.guid = characters_items.ownerguid
    whats the solution on having restriction on viewing and editing characters_items UNLESS they belong to the characters of the account logged in??
    can someone provide examples plse

Sergey Kornilov admin 8/2/2007

You need to move GUID field to Accounts table and use Users can see and edit their own data only.

C
chaz author 8/2/2007

well thats not possible so how do i do it from phprunner? LOL
how do i store a global variable like session and use that to check for the data

Sergey Kornilov admin 8/2/2007

Sure, you can store GUID value in some Session variable and use BeforeSQLQuery Event to add a WHERE clause to the SQL query.

C
chaz author 8/3/2007

All Russian to me !! LOL
Can you give me an example???
using guid is not feasible since they can be many...so using acct is better
How do i carry across the accounts.acct value when using it at onLoad event for example??
As a matter of convenience, how do i make a OwnerID from a table not associated with the login table?

Sergey Kornilov admin 8/3/2007

Here is the example of adding a WHERE clause in BeforeSQLQuery event:
$strSQL = AddWhere($strSQL, "id>3");
or
$strSQL = AddWhere($strSQL, "OwnerIDField = " . $_SESSION["SavedOwnerIDValue"]);
OnwerID field should belong to the login table.

C
chaz author 8/4/2007

where do i put that event?

Sergey Kornilov admin 8/4/2007

BeforeSQLQuery event