Search:

# CWIS Developers Documentation

- Main Page
- Classes
- Files

- Search for |

- File List
- File Members

# Qualifier.php

Go to the documentation of this file.

    00001 <?PHP
    00002
    00003 #
    00004 #   FILE:  SPT--Qualifier.php
    00005 #
    00006 #   METHODS PROVIDED:
    00007 #       Qualifier($QualifierId = NULL)
    00008 #           - constructor (no ID creates new qualifier)
    00009 #       Delete()
    00010 #           - remove qualifier from database
    00011 #       Id()
    00012 #           - get attribute
    00013 #       Name($NewValue = DB_NOVALUE)
    00014 #       Url($NewValue = DB_NOVALUE)
    00015 #           - get/set attributes
    00016 #
    00017 #   AUTHOR:  Edward Almasy
    00018 #
    00019 #   Part of the Scout Portal Toolkit
    00020 #   Copyright 2003 Internet Scout Project
    00021 #   http://scout.wisc.edu
    00022 #
    00023
    00024 class Qualifier {
    00025
    00026     # ---- PUBLIC INTERFACE --------------------------------------------------
    00027
    00028     # object constructor (no ID creates new qualifier)
    00029     function Qualifier($QualifierId = NULL)
    00030     {
    00031         # create our own database handle
    00032         $this->DB = new SPTDatabase();
    00033         $DB =& $this->DB;
    00034
    00035         # if ID supplied
    00036         if ($QualifierId !== NULL)
    00037         {
    00038             # save ID
    00039             $this->Id = intval($QualifierId);
    00040
    00041             # attempt to load qualifier info from database
    00042             $DB->Query("SELECT * FROM Qualifiers"
    00043                     ." WHERE QualifierId = '".$this->Id."'");
    00044
    00045             # if row was loaded
    00046             if ($DB->NumRowsSelected() > 0)
    00047             {
    00048                 # set attributes to values returned by database
    00049                 $this->DBFields = $DB->FetchRow();
    00050             }
    00051         }
    00052         else
    00053         {
    00054             # determine next qualifier ID
    00055             $HighestId = $DB->Query("SELECT QualifierId FROM Qualifiers"
    00056                                     ." ORDER BY QualifierId DESC LIMIT 1", "QualifierId");
    00057             $this->Id = ($HighestId > 0) ? ($HighestId + 1) : 1;
    00058
    00059             # add record to database with that ID
    00060             $DB->Query("INSERT INTO Qualifiers SET QualifierId = ".$this->Id);
    00061         }
    00062     }
    00063
    00064     # remove qualifier from database
    00065     function Delete()
    00066     {
    00067         # delete record from database
    00068         $this->DB->Query("DELETE FROM Qualifiers WHERE QualifierId = ".$this->Id);
    00069     }
    00070
    00071     # get attribute
    00072     function Id() {  return $this->Id;  }
    00073
    00074     # get/set attributes
    00075     function Name($NewValue = DB_NOVALUE) {  return $this->UpdateValue("QualifierName", $NewValue);  }
    00076     function Namespace($NewValue = DB_NOVALUE) {  return $this->UpdateValue("QualifierNamespace", $NewValue);  }
    00077     function Url($NewValue = DB_NOVALUE) {  return $this->UpdateValue("QualifierUrl", $NewValue);  }
    00078
    00079
    00080     # ---- PRIVATE INTERFACE -------------------------------------------------
    00081
    00082     var $Id;
    00083     var $DB;
    00084     var $DBFields;
    00085
    00086     # convenience function to supply parameters to Database->UpdateValue()
    00087     function UpdateValue($FieldName, $NewValue)
    00088     {
    00089         return $this->DB->UpdateValue("Qualifiers", $FieldName, $NewValue,
    00090                                "QualifierId = '".$this->Id."'", $this->DBFields);
    00091     }
    00092 }
    00093
    00094
    00095 ?>