Source for file class.VEREINE.php

Documentation is available at class.VEREINE.php

  1. <?php
  2.  
  3. /**
  4.  * Stellt die Verbindung zur Tabelle 'vereine' her
  5.  *
  6.  * Verwaltet die Vereine
  7.  *
  8.  * @author Kay Koch, <kay.koch@gmx.de>
  9.  * @package src
  10.  * @subpackage foundation_tables
  11.  */
  12.  
  13. if (version_compare(PHP_VERSION'5')) {
  14.     die('This file was generated for PHP 5');
  15. }
  16.  
  17. /**
  18.  * Basisklasse aller Klassen mit Datenbankzugriff.
  19.  *
  20.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  21.  *
  22.  * @author Kay Koch
  23.  * @since 1.12.04
  24.  * @version 1.1
  25.  */
  26. require_once ('src/foundation/tables/class.PARENTTABLES.php');
  27.  
  28. /**
  29.  * Interface für die Klassen zur Manipulation der Datenbanktabellen
  30.  *
  31.  * @author Kay Koch, <kay.koch@gmx.de>
  32.  */
  33. require_once ('src/interfaces/interface.TABLEINTERFACE.php');
  34.  
  35. /* user defined includes */
  36. // section -64--88-122--2-1328c7a:102a6f94cac:-7ffe-includes begin
  37. // section -64--88-122--2-1328c7a:102a6f94cac:-7ffe-includes end
  38.  
  39. /* user defined constants */
  40. // section -64--88-122--2-1328c7a:102a6f94cac:-7ffe-constants begin
  41. // section -64--88-122--2-1328c7a:102a6f94cac:-7ffe-constants end
  42.  
  43. /**
  44.  * Stellt die Verbindung zur Tabelle 'vereine' her
  45.  *
  46.  * Verwaltet die Vereine
  47.  *
  48.  * @access public
  49.  * @author Kay Koch, <kay.koch@gmx.de>
  50.  * @package src
  51.  * @subpackage foundation_tables
  52.  */
  53.     // --- ATTRIBUTES ---
  54.  
  55.     
  56.     /**
  57.      * Beinhaltet den Datenbanknamen (vereine)
  58.      *
  59.      * @access protected
  60.      * @var string 
  61.      */
  62.     protected $dbTableName = 'vereine';
  63.  
  64.     /**
  65.      * array mit allen Vereinen
  66.      *
  67.      * @access private
  68.      * @var array 
  69.      */
  70.     private static $data array ();
  71.  
  72.     /**
  73.      * Id des aktuellen Vereins
  74.      *
  75.      * @access public
  76.      * @var int 
  77.      */
  78.     public $verein_nr = 0;
  79.  
  80.     /**
  81.      * Id des aktuellen Verbandes
  82.      *
  83.      * @access public
  84.      * @var int 
  85.      */
  86.     public $verband_nr = 0;
  87.  
  88.     // --- OPERATIONS ---
  89.  
  90.     
  91.     /**
  92.      * liefert einen (mehrere) Datensatz die durch setzen ser Parameter
  93.      * werden
  94.      *
  95.      * @access public
  96.      * @author Kay Koch, <kay.koch@gmx.de>
  97.      * @return array 
  98.      */
  99.     public function getRow({
  100.         $returnValue array ();
  101.  
  102.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  103.         if (!empty ($this->verein_nrAND !empty ($this->verband_nr))
  104.             $returnValue self :: $data[$this->verband_nr][$this->verein_nr];
  105.         else
  106.             if (!empty ($this->verein_nr))
  107.                 $returnValue self :: $data[$this->verein_nr];
  108.             else
  109.                 $returnValue self :: $data;
  110.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  111.  
  112.         return (array) $returnValue;
  113.     }
  114.  
  115.     /**
  116.      * veranlasst ein Update
  117.      *
  118.      * @access public
  119.      * @author Kay Koch, <kay.koch@gmx.de>
  120.      * @param array 
  121.      * @return boolean 
  122.      */
  123.     public function updateRow($data{
  124.         $returnValue = (bool) false;
  125.  
  126.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 begin
  127.         try {
  128.             $sql "UPDATE IGNORE $this->dbTableName
  129.                     SET verband_nr = '$data['verband_nr'"',
  130.                         verein_nr = '" $data['verein_nr'"',
  131.                         name = '" $data['name'"',
  132.                         stadt = '" $data['stadt'"'
  133.                     WHERE `verein_nr` = '$this->verein_nrAND `verband_nr` ='$this->verband_nr';";
  134.             if (!$this->update($sql))
  135.                 throw new Exception();
  136.             $this->updateData();
  137.             $returnValue true;
  138.         catch (Exception $e{
  139.         }
  140.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 end
  141.  
  142.         return (bool) $returnValue;
  143.     }
  144.  
  145.     /**
  146.      * fügt einen neuen Datensatz ein
  147.      *
  148.      * @access public
  149.      * @author Kay Koch, <kay.koch@gmx.de>
  150.      * @param array 
  151.      * @return boolean 
  152.      */
  153.     public function insertRow($data{
  154.         $returnValue = (bool) false;
  155.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 begin
  156.         try {
  157.             $sql "INSERT  INTO $this->dbTableName
  158.                                                                                                         SET verband_nr = '$data['verband_nr'"',
  159.                                                                                                             verein_nr = '" $data['verein_nr'"',
  160.                                                                                                             name = '" $data['name'"',
  161.                                                                                                             stadt = '" $data['stadt'"'";
  162.             if (!$this->insert($sql))
  163.                 throw new Exception();
  164.             $this->updateData();
  165.             $returnValue true;
  166.         catch (Exception $e{
  167.         }
  168.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 end
  169.  
  170.         return (bool) $returnValue;
  171.     }
  172.  
  173.     /**
  174.      * löscht einen Datensatz
  175.      *
  176.      * @access public
  177.      * @author Kay Koch, <kay.koch@gmx.de>
  178.      * @return boolean 
  179.      */
  180.     public function deleteRow({
  181.         $returnValue = (bool) false;
  182.  
  183.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e begin
  184.         try {
  185.             $sql "DELETE FROM $this->dbTableName WHERE verein_nr = '$this->verein_nrAND verband_nr = '$this->verband_nr'";
  186.             if (!$this->delete($sql))
  187.                 throw new Exception();
  188.             $this->updateData();
  189.             $returnValue true;
  190.         catch (Exception $e{
  191.             ;
  192.         }
  193.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e end
  194.  
  195.         return (bool) $returnValue;
  196.     }
  197.  
  198.     /**
  199.      * aktualisiert die Daten im gegenwertigen Objekt
  200.      *
  201.      * @access public
  202.      * @author Kay Koch, <kay.koch@gmx.de>
  203.      * @return boolean 
  204.      */
  205.     public function updateData({
  206.         $returnValue = (bool) false;
  207.  
  208.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c begin
  209.         $sql "SELECT * FROM  $this->dbTableName ORDER by stadt,name ASC";
  210.         self :: $data $this->select($sqltrue"verband_nr""verein_nr");
  211.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c end
  212.         return (bool) $returnValue;
  213.     }
  214.  
  215.     /**
  216.      * löscht die Parameter, die den gegenwärtigen Datensatz identifizieren
  217.      *
  218.      * @access public
  219.      * @author Kay Koch, <kay.koch@gmx.de>
  220.      * @return void 
  221.      */
  222.     public function unsetParams({
  223.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 begin
  224.         unset ($this->verein_nr);
  225.         unset ($this->verband_nr);
  226.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 end
  227.     }
  228.  
  229.     /**
  230.      * Konstruktor
  231.      *
  232.      * lädt alle Vereine
  233.      *
  234.      * @access public
  235.      * @author Kay Koch, <kay.koch@gmx.de>
  236.      * @return void 
  237.      */
  238.     public function __construct({
  239.         // section -64--88-122--2-1328c7a:102a6f94cac:-7fee begin
  240.         parent :: __construct();
  241.         if (empty (self :: $data)) {
  242.             $this->updateData();
  243.         }
  244.         // section -64--88-122--2-1328c7a:102a6f94cac:-7fee end
  245.     }
  246.  
  247.     /**
  248.      * liefert den Inhalt eines Feldes mit Namen Index aus den Vereinen
  249.      *
  250.      * @access public
  251.      * @author Kay Koch, <kay.koch@gmx.de>
  252.      * @param string 
  253.      * @return string 
  254.      */
  255.     private function __get($index{
  256.         $returnValue = (string) '';
  257.         //
  258.         try {
  259.             if (isset (self :: $data[$this->verband_nr][$this->verein_nr][$index]))
  260.                 $returnValue self :: $data[$this->verband_nr][$this->verein_nr][$index];
  261.         catch (Exception $e{
  262.             src_tools_ERROR :: setError($e__METHOD__);
  263.         }
  264.         //
  265.         return ($returnValue);
  266.     }
  267.  
  268.     /**
  269.      * setzt die Daten für die aktuelle Bearbeitung
  270.      *
  271.      * @access public
  272.      * @author Kay Koch, <kay.koch@gmx.de>
  273.      * @param int 
  274.      * @return void 
  275.      */
  276.     public function setParams($verein_nr{
  277.         // section -64--88-122--2-651443c0:1046f70e203:-7ff1 begin
  278.         list ($this->verband_nr,$this->verein_nr$this-> resolveVereinNr($verein_nr)// Vereinsnummer extrahieren
  279.         // section -64--88-122--2-651443c0:1046f70e203:-7ff1 end
  280.     }
  281.  
  282.     /**
  283.      * überprüft, ob ein Verein existiert
  284.      *
  285.      * @access public
  286.      * @author Kay Koch, <kay.koch@gmx.de>
  287.      * @param string $verein_nr komplette Vereinsnummer (xx/yyyy)
  288.      * @return boolean 
  289.      */
  290.     public function vereinExists($verein_nr{
  291.         list ($verband,$verein$this-> resolveVereinNr($verein_nr)// Vereinsnummer extrahieren
  292.         return isset(self :: $data[$verband][$verein]);
  293.     }
  294.  
  295.     /**
  296.      * zerlegt eine VereinsNr in Verband und Verein
  297.      *
  298.      * @access public
  299.      * @author Kay Koch, <kay.koch@gmx.de>
  300.      * @param string $verein_nr komplette Vereinsnummer (xx/yyyy)
  301.      * @return array [0]:VerbandNr; [1]:VereinNr
  302.      */
  303.     private function resolveVereinNr($verein_nr){
  304.        return array(substr($verein_nr0,2),substr($verein_nr3));
  305.     }
  306. /* end of class src_foundation_tables_VEREINE */
  307. ?>

Documentation generated on Sat, 24 Mar 2007 10:00:13 +0100 by phpDocumentor 1.3.1