Search:

CWIS Developers Documentation

  • Main Page
  • Classes
  • Files
  • 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 (func_num_args()==0)
00036         {
00037             # determine next qualifier ID
00038             $HighestId = $DB->Query(
00039                 "SELECT QualifierId FROM Qualifiers"
00040                 ." ORDER BY QualifierId DESC LIMIT 1", "QualifierId");
00041             $this->Id = ($HighestId > 0) ? ($HighestId + 1) : 1;
00042 
00043             # add record to database with that ID
00044             $DB->Query("INSERT INTO Qualifiers SET QualifierId = ".$this->Id);
00045 
00046         }
00047         # if ID supplied
00048         elseif ($QualifierId !== NULL)
00049         {
00050             # save ID
00051             $this->Id = intval($QualifierId);
00052 
00053             # attempt to load qualifier info from database
00054             $DB->Query("SELECT * FROM Qualifiers"
00055                        ." WHERE QualifierId = '".$this->Id."'");
00056 
00057             # if row was loaded
00058             if ($DB->NumRowsSelected() > 0)
00059             {
00060                 # set attributes to values returned by database
00061                 $this->DBFields = $DB->FetchRow();
00062             }
00063         }
00064     }
00065 
00066     # remove qualifier from database
00067     function Delete()
00068     {
00069         # delete record from database
00070         $this->DB->Query("DELETE FROM Qualifiers WHERE QualifierId = ".$this->Id);
00071     }
00072 
00073     # get attribute
00074     function Id() {  return $this->Id;  }
00075 
00076     # get/set attributes
00077     function Name($NewValue = DB_NOVALUE) {  return $this->UpdateValue("QualifierName", $NewValue);  }
00078     function NSpace($NewValue = DB_NOVALUE) {  return $this->UpdateValue("QualifierNamespace", $NewValue);  }
00079     function Url($NewValue = DB_NOVALUE) {  return $this->UpdateValue("QualifierUrl", $NewValue);  }
00080 
00081 
00082     # ---- PRIVATE INTERFACE -------------------------------------------------
00083 
00084     var $Id;
00085     var $DB;
00086     var $DBFields;
00087 
00088     # convenience function to supply parameters to Database->UpdateValue()
00089     function UpdateValue($FieldName, $NewValue)
00090     {
00091         return $this->DB->UpdateValue("Qualifiers", $FieldName, $NewValue,
00092                                "QualifierId = '".$this->Id."'", $this->DBFields);
00093     }
00094 }
00095 
00096 
00097 ?>

CWIS logo doxygen
Copyright 2010 Internet Scout