Source for file class.PARENTTABLES.php

Documentation is available at class.PARENTTABLES.php

  1. <?php
  2.  
  3. /**
  4.  * Basisklasse aller Klassen mit Datenbankzugriff.
  5.  *
  6.  * stellt Methoden und Objekte zur Fehlermeldung und zum Datenbankzugriff zur
  7.  *
  8.  * @author Kay Koch
  9.  * @package src
  10.  * @since 1.12.04
  11.  * @subpackage foundation_tables
  12.  * @version 1.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.  * @access public
  25.  * @author Kay Koch
  26.  * @package src
  27.  * @since 1.12.04
  28.  * @subpackage foundation_tables
  29.  * @version 1.1
  30.  */
  31.     // --- ATTRIBUTES ---
  32.  
  33.     
  34.     /**
  35.      * ermöglicht den Datenbankzugriff
  36.      *
  37.      * @access private
  38.      * @var DB 
  39.      */
  40.     private static $oDBnull;
  41.  
  42.     /**
  43.      * aktueller See
  44.      *
  45.      * @access private
  46.      * @var EINSEE 
  47.      */
  48.     private static $oSeenull;
  49.  
  50.     /**
  51.      * alle Seen
  52.      *
  53.      * @access private
  54.      * @var SEEN 
  55.      */
  56.     protected static $oSeennull;
  57.  
  58.     /**
  59.      * Datum des nächsten Backups
  60.      *
  61.      * @access private
  62.      * @var EINSEE 
  63.      */
  64.     private static $oFlagsnull;
  65.  
  66.     private static $oKontakte null;
  67.     // --- OPERATIONS ---
  68.  
  69.     
  70.     /**
  71.      * fügt laut übergebenen SQL-String in Datenbank ein
  72.      *
  73.      * Bei einer automatischen Inkrementierung wird die ID des neuen Datensatzes
  74.      *
  75.      * @access protected
  76.      * @author Kay Koch, <kay.koch@gmx.de>
  77.      * @param string 
  78.      * @return int 
  79.      */
  80.     protected function insert($sql{
  81.         $returnValue= (int) 0;
  82.  
  83.         // section -64--88-122--2-f41e9:1009a89d5b2:-7f41 begin
  84.         try {
  85.             if (empty ($sql))
  86.                 throw new Exception(1);
  87.             if (!eregi("^insert"$sql))
  88.                 throw new Exception(2);
  89.             $resultsself :: $oDB->query($sql);
  90.             if ((!$results))
  91.                 throw new Exception(3);
  92.             $newID self :: $oDB->insert_id();
  93.             $returnValue ($newID$newID true;
  94.         catch (Exception $e{
  95.             src_tools_ERROR :: setError($e__METHOD__);
  96.         }
  97.  
  98.         // section -64--88-122--2-f41e9:1009a89d5b2:-7f41 end
  99.  
  100.         return (int) $returnValue;
  101.     }
  102.  
  103.     /**
  104.      * löscht laut übergebenen SQL-String aus Datenbank
  105.      *
  106.      * @access protected
  107.      * @author Kay Koch, <kay.koch@gmx.de>
  108.      * @param string 
  109.      * @return boolean 
  110.      */
  111.     protected function delete($sql{
  112.         $returnValue= (bool) false;
  113.  
  114.         try {
  115.             if (empty ($sql))
  116.                 throw new Exception(1);
  117.             if (!eregi("^delete"$sql))
  118.                 throw new Exception(2);
  119.             $resultsself :: $oDB->query($sql);
  120.             if ((!$results))
  121.                 throw new Exception(3);
  122.             $returnValuemysql_affected_rows();
  123.         catch (Exception $e{
  124.             src_tools_ERROR :: setError($e__METHOD__);
  125.         }
  126.  
  127.         return (bool) $returnValue;
  128.     }
  129.  
  130.     /**
  131.      * liest Daten laut übergebenen SQL-String aus Datenbank ein
  132.      *
  133.      * @access protected
  134.      * @author Kay Koch, <kay.koch@gmx.de>
  135.      * @param string 
  136.      * @param boolean 
  137.      * @param string 
  138.      * @param string 
  139.      * @param string 
  140.      * @return array 
  141.      */
  142.     protected function select($sql$asArraytrue$key1''$key2''$key3''{
  143.         $returnValuearray ();
  144.  
  145.         try {
  146.             if (empty ($sql))
  147.                 throw new Exception(1);
  148.             if (!eregi("^select"$sql))
  149.                 throw new Exception(2);
  150.             $resultsself :: $oDB->query($sql);
  151.             if ((!$resultsOR empty ($results))
  152.                 throw new Exception(3);
  153.             if (self :: $oDB->num_rows($results== AND !$asArray{
  154.                 $returnValueself :: $oDB->fetch_array($resultsMYSQL_ASSOC);
  155.             else
  156.                 if (!empty ($key1AND !empty ($key2AND !empty ($key3)) {
  157.                     while ($rowself :: $oDB->fetch_array($resultsMYSQL_ASSOC))
  158.                         $returnValue[$row[$key1]][$row[$key2]][$row[$key3]]$row;
  159.                 else
  160.                     if (!empty ($key1AND !empty ($key2)) {
  161.                         while ($rowself :: $oDB->fetch_array($resultsMYSQL_ASSOC))
  162.                             $returnValue[$row[$key1]][$row[$key2]]$row;
  163.                     else
  164.                         if (!empty ($key1)) {
  165.                             while ($rowself :: $oDB->fetch_array($resultsMYSQL_ASSOC))
  166.                                 $returnValue[$row[$key1]]$row;
  167.                         else {
  168.                             while ($rowself :: $oDB->fetch_array($resultsMYSQL_ASSOC))
  169.                                 array_push($returnValue$row);
  170.                         }
  171.  
  172.             self :: $oDB->free_result($results);
  173.         catch (Exception $e{
  174.             src_tools_ERROR :: setError($e__METHOD__);
  175.         }
  176.  
  177.         return (array) $returnValue;
  178.     }
  179.  
  180.     /**
  181.      * aktualisiert laut übergebenen SQL-String Daten in Datenbank
  182.      *
  183.      * @access protected
  184.      * @author Kay Koch, <kay.koch@gmx.de>
  185.      * @param string 
  186.      * @return int 
  187.      */
  188.     protected function update($sql{
  189.         $returnValue= (int) 0;
  190.  
  191.         try {
  192.             if (empty ($sql))
  193.                 throw new Exception(1);
  194.             if (!eregi("^update"$sql))
  195.                 throw new Exception(2);
  196.             $resultsself :: $oDB->query($sql);
  197.             if ((!$results))
  198.                 throw new Exception(3);
  199.             $returnValuemysql_affected_rows();
  200.         catch (Exception $e{
  201.             src_tools_ERROR :: setError($e__METHOD__);
  202.         }
  203.  
  204.         return (int) $returnValue;
  205.     }
  206.  
  207.     /**
  208.      * leert laut übergebenen SQL-String Daten in Datenbank
  209.      *
  210.      * @access protected
  211.      * @author Kay Koch, <kay.koch@gmx.de>
  212.      * @param string 
  213.      * @return int 
  214.      */
  215.     protected function truncate($sql{
  216.         $returnValue= (boolean) false;
  217.  
  218.         try {
  219.             if (empty ($sql))
  220.                 throw new Exception(1);
  221.             if (!eregi("^truncate"$sql))
  222.                 throw new Exception(2);
  223.             $resultsself :: $oDB->query($sql);
  224.             if ((!$results))
  225.                 throw new Exception(3);
  226.             $returnValuetrue;
  227.         catch (Exception $e{
  228.             src_tools_ERROR :: setError($e__METHOD__);
  229.         }
  230.  
  231.         return (int) $returnValue;
  232.     }
  233.  
  234.     /**
  235.      * Konstruktor
  236.      *
  237.      * erstellt ein Datenbankobjekt
  238.      *
  239.      * @access public
  240.      * @author Kay Koch, <kay.koch@gmx.de>
  241.      * @return void 
  242.      */
  243.     public function __construct({
  244.         if (self :: $oDB == null{
  245.             self :: $oDBnew src_foundation_db_DB(src_foundation_db_DBDATA :: getData());
  246.         }
  247.     }
  248.  
  249.     /**
  250.      * liefert den aktuellen See
  251.      *
  252.      * @access public
  253.      * @author Kay Koch, <kay.koch@gmx.de>
  254.      * @return src_foundation_datatypes_EINSEE 
  255.      */
  256.     public static function getSea({
  257.         return self :: $oSee;
  258.     }
  259.  
  260.     /**
  261.      * legt den aktuellen See fest
  262.      *#
  263.      * @access public
  264.      * @author Kay Koch, <kay.koch@gmx.de>
  265.      * @param $see_id ID des Sees
  266.      * @return void 
  267.      */
  268.     public static function setSea($see_id{
  269.         self :: $oSeeself :: $oSeen-> $see_id;
  270.     }
  271.  
  272.     /** liefert das Objekt oSeen
  273.      *
  274.      * @access public
  275.      * @author Kay Koch, <kay.koch@gmx.de>
  276.      * @return src_foundation_tables_SEEN 
  277.      */
  278.     public static function getSeen($id=""{
  279.         $returnValue (empty($id))?self :: $oSeenself :: $oSeen->$id;
  280.         return $returnValue;
  281.     }
  282.     /**
  283.      * speichert die Seen
  284.      *
  285.      * @access public
  286.      * @author Kay Koch, <kay.koch@gmx.de>
  287.      * @param src_foundation_tables_SEEN $oSeen 
  288.      * @return void 
  289.      */
  290.     protected static function setSeen($oSeen{
  291.         self :: $oSeen$oSeen;
  292.     }
  293.  
  294.     /** liefert das Objekt oFlags
  295.      *
  296.      * @access public
  297.      * @author Kay Koch, <kay.koch@gmx.de>
  298.      * @return src_foundation_tables_FLAGS 
  299.      */
  300.     public static function getFlags({
  301.         return self :: $oFlags;
  302.     }
  303.  
  304.     /** setzt das Objekt oFlags
  305.      *
  306.      * @access protected
  307.      * @author Kay Koch, <kay.koch@gmx.de>
  308.      * @param src_foundation_tables_FLAGS $oFlags 
  309.      * @return void 
  310.      */
  311.     protected static function setFlags($oFlags{
  312.         self :: $oFlags$oFlags;
  313.     }
  314.  
  315.     /** liefert das Objekt oKontakte
  316.      *
  317.      * @access public
  318.      * @author Kay Koch, <kay.koch@gmx.de>
  319.      * @return src_foundation_tables_KONTAKTE 
  320.      */
  321.     public static function getKontakte($id=""{
  322.         $returnValue (empty($id))?self :: $oKontakteself :: $oKontakte->$id;
  323.         return $returnValue;
  324.     }
  325.  
  326.     /** setzt das Objekt oFlags
  327.      *
  328.      * @access protected
  329.      * @author Kay Koch, <kay.koch@gmx.de>
  330.      * @param src_foundation_tables_FLAGS $oFlags 
  331.      * @return void 
  332.      */
  333.     protected static function setKontakte($oKontakte{
  334.         self :: $oKontakte $oKontakte;
  335.     }
  336.  
  337.     /**
  338.      * liefert ein Array mit den Spaltennamen der aktuellen Tabelle
  339.      *
  340.      * @access public
  341.      * @author Kay Koch, <kay.koch@gmx.de>
  342.      * @return array 
  343.      */
  344.     public function getArrKeys({
  345.         return self :: $oDB->getFieldNames($this->dbTableName);
  346.     }
  347.  
  348.     /**
  349.      * Optimiert Datenbank
  350.      *
  351.      * @access protected
  352.      * @author Kay Koch, <kay.koch@gmx.de>
  353.      * @return boolean 
  354.      */
  355.     protected function optimizeDB({
  356.         self :: $oDB->optimizeDB();
  357.     }
  358.  
  359.     /**
  360.      * liefert den Tabellennamen der aktuellen Tabelle
  361.      *
  362.      * @access public
  363.      * @author Kay Koch, <kay.koch@gmx.de>
  364.      * @return string 
  365.      */
  366.     public function getTableName({
  367.         return $this->dbTableName;
  368.     }
  369. /* end of class src_foundation_tables_PARENTTABLES */
  370. ?>

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