Source for file class.MAXFREI.php

Documentation is available at class.MAXFREI.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * Stellt die Verbindung zur Datenbank 'maxfrei' her
  6.  * Stellt Methoden zum Auslesen und schreiben in diese Datenbank zur Verfügung
  7.  *
  8.  * @author Kay Koch
  9.  * @package src
  10.  * @since 1.12.04
  11.  * @subpackage foundation_tables
  12.  * @version 1
  13.  */
  14.  
  15. if (version_compare(PHP_VERSION'5')) {
  16.     die('This file was generated for PHP 5');
  17. }
  18.  
  19. /**
  20.  * Basisklasse aller Klassen mit Datenbankzugriff.
  21.  *
  22.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  23.  *
  24.  * @author Kay Koch
  25.  * @since 1.12.04
  26.  * @version 1.1
  27.  */
  28. require_once('src/foundation/tables/class.PARENTTABLES.php');
  29.  
  30. /**
  31.  * Interface für die Klassen zur Manipulation der Datenbanktabellen
  32.  *
  33.  * @author Kay Koch, <kay.koch@gmx.de>
  34.  */
  35. require_once('src/interfaces/interface.TABLEINTERFACE.php');
  36.  
  37. /* user defined includes */
  38. // section -64--88-122--2-1989b5:1009961f3dd:-7fd4-includes begin
  39. // section -64--88-122--2-1989b5:1009961f3dd:-7fd4-includes end
  40.  
  41. /* user defined constants */
  42. // section -64--88-122--2-1989b5:1009961f3dd:-7fd4-constants begin
  43. // section -64--88-122--2-1989b5:1009961f3dd:-7fd4-constants end
  44.  
  45. /**
  46.  * Stellt die Verbindung zur Datenbank 'maxfrei' her
  47.  * Stellt Methoden zum Auslesen und schreiben in diese Datenbank zur Verfügung
  48.  *
  49.  * @access public
  50.  * @author Kay Koch
  51.  * @package src
  52.  * @since 1.12.04
  53.  * @subpackage foundation_tables
  54.  * @version 1
  55.  */
  56.         implements src_interfaces_TABLEINTERFACE
  57. {
  58.     // --- ATTRIBUTES ---
  59.  
  60.     
  61.     /**
  62.      * Beinhaltet den Datenbanknamen (maxfrei)
  63.      *
  64.      * @access protected
  65.      * @var string 
  66.      */
  67.     protected $dbTableName = 'maxfrei';
  68.  
  69.     /**
  70.      * array mit allen maximal freien Plätzen
  71.      *
  72.      * @access private
  73.      * @var array 
  74.      */
  75.     private static $data array();
  76.  
  77.     /**
  78.      * aktuelle see_id
  79.      *
  80.      * @access public
  81.      * @var int 
  82.      */
  83.     public $see_id = 0;
  84.  
  85.     /**
  86.      * aktueller Wochentag
  87.      *
  88.      * @access public
  89.      * @var int 
  90.      */
  91.     public $wochentag = 0;
  92.  
  93.    /**
  94.      * Feld mit deutschen Feiertagen
  95.      *
  96.      * @access public
  97.      * @var array 
  98.      */
  99.     public $arrFeiertage =array();
  100.  
  101.     // --- OPERATIONS ---
  102.  
  103.     
  104.     /**
  105.      * liefert einen (mehrere) Datensatz die durch setzen ser Parameter
  106.      * werden
  107.      *
  108.      * @access public
  109.      * @author Kay Koch, <kay.koch@gmx.de>
  110.      * @return array 
  111.      */
  112.     public function getRow()
  113.     {
  114.         $returnValue array();
  115.  
  116.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab begin
  117.         if (!empty($this->see_idAND !empty($this->wochentag))
  118.             $returnValue self::$data[$this->see_id][$this->wochentag];
  119.         else if (!empty($this->see_id))
  120.             $returnValue self::$data[$this->see_id];
  121.         else
  122.             $returnValue self::$data;
  123.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fab end
  124.  
  125.         return (array) $returnValue;
  126.     }
  127.  
  128.     /**
  129.      * veranlasst ein Update
  130.      *
  131.      * @access public
  132.      * @author Kay Koch, <kay.koch@gmx.de>
  133.      * @param array 
  134.      * @return boolean 
  135.      */
  136.     public function updateRow($data)
  137.     {
  138.         $returnValue = (bool) false;
  139.  
  140.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 begin
  141.         try {
  142.             $data['sumTag'array_sum($data);
  143.             $sql "UPDATE  IGNORE $this->dbTableName SET  ";
  144.             foreach($data as $key => $value$sql .= " `$key` = '$value',";
  145.             $sql substr($sql0-1);
  146.             $sql .= " WHERE see_id = '$this->see_idAND wochentag='$this->wochentag'";
  147.             if (!$this->update($sql))
  148.                 throw new Exception ();
  149.             $this->updateData();
  150.             $returnValue true;
  151.         }
  152.         catch (Exception $e{;
  153.         }
  154.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa9 end
  155.  
  156.         return (bool) $returnValue;
  157.     }
  158.  
  159.     /**
  160.      * fügt einen neuen Datensatz ein
  161.      *
  162.      * @access public
  163.      * @author Kay Koch, <kay.koch@gmx.de>
  164.      * @param array 
  165.      * @return boolean 
  166.      */
  167.     public function insertRow($data)
  168.     {
  169.         $returnValue = (bool) false;
  170.  
  171.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 begin
  172.         try {
  173.             $sql "INSERT IGNORE INTO $this->dbTableName (`see_id`, `wochentag`) VALUES ";
  174.             for ($weekday 1$weekday <= 7$weekday++{
  175.                 $sql .= "('$this->see_id' , '$weekday "'),";
  176.             }
  177.             $sql substr($sql0-1";";
  178.             if (!$this->insert($sql))
  179.                 throw new Exception ();
  180.             $this->updateData();
  181.             $returnValue true;
  182.         }
  183.         catch (Exception $e{
  184.         }
  185.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7fa6 end
  186.  
  187.         return (bool) $returnValue;
  188.     }
  189.  
  190.     /**
  191.      * löscht einen Datensatz
  192.      *
  193.      * @access public
  194.      * @author Kay Koch, <kay.koch@gmx.de>
  195.      * @return boolean 
  196.      */
  197.     public function deleteRow()
  198.     {
  199.         $returnValue = (bool) false;
  200.  
  201.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e begin
  202.         try {
  203.             $sql "DELETE FROM $this->dbTableName WHERE see_id = '$this->see_id'";
  204.             if (!$this->delete($sql))
  205.                 throw new Exception ();
  206.             $this->updateData();
  207.             $returnValue true;
  208.         }
  209.         catch (Exception $e{;
  210.         }
  211.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9e end
  212.  
  213.         return (bool) $returnValue;
  214.     }
  215.  
  216.     /**
  217.      * aktualisiert die Daten im gegenwertigen Objekt
  218.      *
  219.      * @access public
  220.      * @author Kay Koch, <kay.koch@gmx.de>
  221.      * @return boolean 
  222.      */
  223.     public function updateData()
  224.     {
  225.         $returnValue = (bool) false;
  226.  
  227.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c begin
  228.         $sql "SELECT  * FROM " $this->dbTableName . " ORDER by see_id, wochentag ASC";
  229.         self::$data $this->select($sqltrue"see_id""wochentag");
  230.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f9c end
  231.  
  232.         return (bool) $returnValue;
  233.     }
  234.  
  235.     /**
  236.      * löscht die Parameter, die den gegenwärtigen Datensatz identifizieren
  237.      *
  238.      * @access public
  239.      * @author Kay Koch, <kay.koch@gmx.de>
  240.      * @return void 
  241.      */
  242.     public function unsetParams()
  243.     {
  244.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 begin
  245.         unset($this->see_id);
  246.         unset($this->wochentag);
  247.         // section -64--88-122--2--3d9a0b58:1040f000f1b:-7f97 end
  248.     }
  249.  
  250.     /**
  251.      * setzt die Daten für die aktuelle Bearbeitung
  252.      *
  253.      * @access public
  254.      * @author Kay Koch, <kay.koch@gmx.de>
  255.      * @param int 
  256.      * @param date 
  257.      * @param int 
  258.      * @return void 
  259.      */
  260.     public function setParams($see_id$datum null$wochentag 0)
  261.     {
  262.         // section -64--88-122--2--994e15c:10441f6e853:-7fc0 begin
  263.         $this->see_id = $see_id;
  264.         if (!empty($datum))
  265.             $this->wochentag = (in_array($datum$this->arrFeiertage)) src_tools_TIME :: sqlT2realT($datum"%w");
  266.         if (!empty($wochentag))
  267.             $this->wochentag = $wochentag;
  268.         // section -64--88-122--2--994e15c:10441f6e853:-7fc0 end
  269.     }
  270.  
  271.     /**
  272.      * Konstruktor
  273.      *
  274.      * lädt alle maximalen freien Plätze
  275.      *
  276.      * @access public
  277.      * @author Kay Koch, <kay.koch@gmx.de>
  278.      * @return void 
  279.      */
  280.     public function __construct()
  281.     {
  282.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fed begin
  283.         parent::__construct();
  284.         if (empty(self::$data)){
  285.             $this->updateData();
  286.             $this->arrFeiertage = src_tools_TIME::getFeiertage();
  287.         }
  288.  
  289.         // section -64--88-122--2-7471698e:1046ab3b89c:-7fed end
  290.     }
  291.  
  292. /* end of class src_foundation_tables_MAXFREI */
  293.  
  294. ?>

Documentation generated on Sat, 24 Mar 2007 09:59:37 +0100 by phpDocumentor 1.3.1