Search:

# CWIS Developers Documentation

- Main Page
- Classes
- Files

- Search for |

- File List
- File Members

# QualifierFactory.php

Go to the documentation of this file.

    00001 <?PHP
    00002
    00003 #
    00004 #   FILE:  SPT--QualifierFactory.php
    00005 #
    00006 #   METHODS PROVIDED:
    00007 #       QualifierFactory()
    00008 #           - constructor
    00009 #       QualifierList()
    00010 #           - return list of all qualifiers
    00011 #       QualifierCount()
    00012 #           - return count of qualifiers
    00013 #       QualifierNameIsInUse($Name)
    00014 #           - return whether qualifier name is in use
    00015 #
    00016 #   AUTHOR:  Edward Almasy
    00017 #
    00018 #   Part of the Scout Portal Toolkit
    00019 #   Copyright 2003 Internet Scout Project
    00020 #   http://scout.wisc.edu
    00021 #
    00022
    00023 class QualifierFactory {
    00024
    00025     # ---- PUBLIC INTERFACE --------------------------------------------------
    00026
    00027     # object constructor
    00028     function QualifierFactory()
    00029     {
    00030         # create database handle for our use
    00031         $this->DB = new SPTDatabase();
    00032     }
    00033
    00034     # return list of all qualifiers
    00035     function QualifierList()
    00036     {
    00037         # retrieve list of qualifiers
    00038         $this->DB->Query("SELECT QualifierId, QualifierName FROM Qualifiers"
    00039                 ." ORDER BY QualifierName");
    00040         return $this->DB->FetchColumn("QualifierName", "QualifierId");
    00041     }
    00042
    00043     # return count of qualifiers
    00044     function QualifierCount()
    00045     {
    00046         # retrieve count of qualifiers
    00047         return $this->DB->Query("SELECT COUNT(*) AS RecordCount FROM Qualifiers",
    00048                 "RecordCount");
    00049     }
    00050
    00051     # return whether qualifier name is in use
    00052     function QualifierNameIsInUse($Name)
    00053     {
    00054         # query whether name is in use
    00055         $RecordCount = $this->DB->Query("SELECT COUNT(*) AS RecordCount FROM Qualifiers"
    00056                 ." WHERE UPPER(QualifierName) = '".addslashes(strtoupper($Name))."'",
    00057                 "RecordCount");
    00058
    00059         # return result to caller
    00060         return ($RecordCount > 0) ? TRUE : FALSE;
    00061     }
    00062
    00063     # retrieve qualifier by name
    00064     function GetQualifierByName($QualifierName)
    00065     {
    00066         # query database for qualifier ID
    00067         $QualifierId = $this->DB->Query("SELECT QualifierId FROM Qualifiers"
    00068                 ." WHERE QualifierName = '".addslashes($QualifierName)."'",
    00069                 "QualifierId");
    00070
    00071         # create qualifier object and return to caller
    00072         return new Qualifier($QualifierId);
    00073     }
    00074
    00075
    00076     # ---- PRIVATE INTERFACE -------------------------------------------------
    00077
    00078     var $DB;
    00079 }
    00080
    00081
    00082 ?>