Fork me on GitHub

need help with logic of a settings database.  Bottom

  • Writing a multiguild support guild managment tool. I have a need to have individual settings per guild.

    I have 3 tables that are concerned with the problem currently.
    Guild database > gid is the primary key
    stype database > stypeid is the key (this basicly allows me to add various settings and it will autopopulate with some default values for all guilds.

    settings database > sid is the key. it references gid stypeid and has a value field to store the values for each setting per guild.

    I have the add/delete/update all that working fine. My problem is this.

    Lets say I am in the guild managment template for gid 1.

    I want to beable to reference the settings information so I query out the settings info (I believe its how I am storeing the values thats making this behave this incorrectly.)

    Currently I have to reference the values by say $settings[0].value I want to be able to get the value of the setting by $settings[0].name.

    Code

    for (; !$results->EOF; $results->MoveNext()) {
            list($sid, $gid, $stypeid, $value) = $results->fields;
            $output[] = array(  'sid' => $sid,
                                'gid' => $gid,
                                'sname' => pnModAPIFunc(pnguildmgr, user, getstypename, array('stypeid' => $stypeid)),
                                'value' => $value);
        }


    This is how I am feeding my info into my array.

    Any ideas?
  • Ah I think I solved my own problem.

    Code

    for (; !$results->EOF; $results->MoveNext()) {
            list($sid, $gid, $stypeid, $value) = $results->fields;
            $sname=pnModAPIFunc(pnguildmgr, user, getstypename, array('stypeid' => $stypeid));
            $output[] = array(  'sid'   => $sid,
                                'gid'   => $gid,
                                'sname' => $sname,
                                'value' => $value,
                                $sname => $value);
        }


    Seemed to do the trick.
  • :) sometimes u just gotta take 2 steps back to see the problem
  • LOL Yeah I no sooner figured out how to explain what I was trying to do hit submit and said oh duh. hehe.

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