databases
[ class tree: databases ] [ index: databases ] [ all elements ]

Source for file ABSTDatabaseHost.class.php

Documentation is available at ABSTDatabaseHost.class.php

  1. <?php
  2. /**
  3.  * For including this file you have to define the constant "CLASSPATH".
  4.  * Because every include in the framework depends on the CLASSPATH definition.
  5.  * The CLASSPATH means the relative path to the folder that contains the
  6.  * framework GilliGan.
  7.  *
  8.  * @package databases
  9.  */
  10. if!defined"CLASSPATH" ) )
  11. {
  12.   echo "<h3>You have to define the constant CLASSPATH!</h3>\r\n";
  13.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\r\n";
  14.   exit();
  15. }
  16.  
  17. /**
  18.  *
  19.  */
  20. require_onceCLASSPATH."settings.inc.php" );
  21. /**
  22.  *
  23.  */
  24. require_onceCLASSPATH."DebuggingSettings.inc.php" );
  25.  
  26. /**
  27.  * @abstract
  28.  * @package   databases
  29.  * @version   0.1.44
  30.  * @author    Daniel Plücken <daniel@debakel.net>
  31.  * @license   http://www.gnu.org/copyleft/lesser.html
  32.  *             GNU Lesser General Public License
  33.  * @copyright Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>
  34.  *
  35.  *  This library is free software; you can redistribute it and/or
  36.  *  modify it under the terms of the GNU Lesser General Public
  37.  *  License as published by the Free Software Foundation; either
  38.  *  version 2.1 of the License.
  39.  *
  40.  *  This library is distributed in the hope that it will be useful,
  41.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  42.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  43.  *  GNU Lesser General Public License for more details.
  44.  *
  45.  *  You should have received a copy of the GNU Lesser General
  46.  *  Public License along with this library; if not, write to the
  47.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  48.  *  Boston, MA 02111-1307 USA
  49.  */
  50. {
  51.   /**
  52.    * The Name of the databasehost.
  53.    *
  54.    * @var    string $name 
  55.    * @access public
  56.    */
  57.   var $name;
  58.   /**
  59.    * The connection's port.
  60.    *
  61.    * @var    int    $port 
  62.    * @access public
  63.    */
  64.   var $port;
  65.   /**
  66.    * The username to log on the database server.
  67.    *
  68.    * @var    string $user 
  69.    * @access public
  70.    */
  71.   var $user;
  72.   /**
  73.    * The password to log on the database server.
  74.    *
  75.    * @var    string $password 
  76.    * @access public
  77.    */
  78.   var $password;
  79.   /**
  80.    * Carries the references to objects of databases.
  81.    *
  82.    * @var    array   $db 
  83.    * @access private
  84.    */
  85.   var $db;
  86.   /**
  87.    * @var    object $resID 
  88.    * @access public
  89.    */
  90.   var $resID;
  91.   /**
  92.    * The connection's state of the databasehost.
  93.    *
  94.    * @var    boolean $is_connected 
  95.    * @access private
  96.    */
  97.   var $is_connected = false;
  98.   /**
  99.    * Carries the name of a function which has to be invoked on a connection
  100.    * error.
  101.    *
  102.    * @access public
  103.    * @var    function $error_callback 
  104.    */
  105.   var $error_callback = null;
  106.  
  107.  
  108.  
  109.    /**
  110.     * Fake-Constructor
  111.     *
  112.     * @version 1.0
  113.     * @since   0.1.3
  114.     * @author  Daniel Plücken <daniel@debakel.net>
  115.     * @access  public
  116.     */
  117.   function ABSTDatabaseHost()
  118.   {
  119.     echo "<h3>This is an abstract class. "
  120.             ."You cannot get an instance of it!</h3>";
  121.     exit();
  122.   }
  123.  
  124.  
  125.  
  126.    /**
  127.     * Constructor.
  128.     * All parameter are optional.
  129.     *
  130.     * @version 1.0
  131.     * @since   0.1.3
  132.     * @author  Daniel Plücken <daniel@debakel.net>
  133.     * @access  public
  134.     * @param   string  $host     The host on which the database server runs.
  135.     * @param   string  $user     The user to log on the database host.
  136.     * @param   string  $password The password to log on the database host.
  137.     * @param   string  $port     The port on which should be the communication.
  138.     */
  139.   function __constructor(
  140.                            $host     "localhost",
  141.                            $user     "",
  142.                            $password "",
  143.                            $port     ""
  144.                         )
  145.   {
  146.     $this->name     = $host;
  147.     $this->user     = $user;
  148.     $this->password = $password;
  149.     $this->port     = $port;
  150.   }
  151.  
  152.  
  153.  
  154.   /**
  155.    * Sets the name of the function that should be invoked on a connection error.
  156.    * The function to call back has to have two parameter. The first parameter is
  157.    * for the error code. The second one contains the errordescription.
  158.    *
  159.    * @version 1.0
  160.    * @since   0.1.43
  161.    * @author  Daniel Plücken <daniel@debakel.net>
  162.    * @access  public
  163.    * @param   string $function_name_str 
  164.    * @return  void 
  165.    */
  166.   function setConnectionErrorCallback$function_name_str )
  167.   $this->error_callback = $function_name_str}
  168.  
  169.  
  170.  
  171.   /**
  172.    * Sets the hostname.
  173.    *
  174.    * @version 1.0
  175.    * @since   0.1.0
  176.    * @author  Daniel Plücken <daniel@debakel.net>
  177.    * @access  public
  178.    * @param   string 
  179.    * @return  void 
  180.    */
  181.   function setHost$string )
  182.   $this->name = $string}
  183.  
  184.  
  185.  
  186.   /**
  187.    * Sets the hostname. This method is an alias of the method setHost( $string ).
  188.    *
  189.    * @version 1.0
  190.    * @since   0.1.0
  191.    * @author  Daniel Plücken <daniel@debakel.net>
  192.    * @access  public
  193.    * @param   string $string 
  194.    * @return  void 
  195.    */
  196.   function setName$string )
  197.   $this->name = $string}
  198.  
  199.  
  200.  
  201.   /**
  202.    * Specifies the port that should be used to connect to the host.
  203.    *
  204.    * @version 1.0
  205.    * @since   0.1.0
  206.    * @author  Daniel Plücken <daniel@debakel.net>
  207.    * @access  public
  208.    * @param   int    $int 
  209.    * @return  void 
  210.    */
  211.   function setPort$int )
  212.   $this->port = $int}
  213.  
  214.  
  215.  
  216.   /**
  217.    * Specifies the user who should connect with to the host.
  218.    *
  219.    * @version 1.0
  220.    * @since   0.1.0
  221.    * @author  Daniel Plücken <daniel@debakel.net>
  222.    * @access  public
  223.    * @param   string $string 
  224.    * @return  void 
  225.    */
  226.   function setUser$string )
  227.   {  $this->user = $string}
  228.  
  229.  
  230.  
  231.   /**
  232.    * Sets the password that should be used to connect to the host.
  233.    *
  234.    * @version 1.0
  235.    * @since   0.1.0
  236.    * @author  Daniel Plücken <daniel@debakel.net>
  237.    * @access  public
  238.    * @param   string $string 
  239.    * @return  void 
  240.    */
  241.   function setPassword$string )
  242.   {  $this->password = $string}
  243.  
  244.  
  245.  
  246.   /**
  247.    * Adds a database's reference to this object of a database host.
  248.    *
  249.    * @version 1.1
  250.    * @since   0.1.0
  251.    * @author  Daniel Plücken <daniel@debakel.net>
  252.    * @access  public
  253.    * @param   object  $dbt_obj 
  254.    * @return  void 
  255.    */
  256.   function addDB&$db_obj )
  257.   {
  258.     if(
  259.         !function_exists"is_a" )
  260.      && (
  261.           get_class$db_obj == "database"
  262.        || get_parent_class$db_obj == "database"
  263.         )
  264.       )
  265.     {
  266.       $db_obj->setParent$this );
  267.       $this->db[&$db_obj;
  268.     }
  269.     else
  270.     if(
  271.         function_exists"is_a" )
  272.      && (
  273.           is_a$db_obj"Database" )
  274.        || is_subclass_of$db_obj"database" )
  275.         )
  276.       )
  277.     {
  278.       $db_obj->setParent$this );
  279.       $this->db[&$db_obj;
  280.     }
  281.     else
  282.       die(
  283.            "<h3>The parameter does not refer to "
  284.               ."a valid object of a database!</h3>"
  285.          );
  286.   }
  287.  
  288.  
  289.  
  290.   /**
  291.    * Returns the hostname.
  292.    *
  293.    * @version 1.0
  294.    * @since   0.1.0
  295.    * @author  Daniel Plücken <daniel@debakel.net>
  296.    * @access  public
  297.    * @return  string 
  298.    */
  299.   function getHost()
  300.   return $this->name}
  301.  
  302.  
  303.  
  304.   /**
  305.    * Returns the hostname. This method is an alias of the method getHost().
  306.    *
  307.    * @version 1.0
  308.    * @since   0.1.0
  309.    * @author  Daniel Plücken <daniel@debakel.net>
  310.    * @access  public
  311.    * @return  string 
  312.    */
  313.   function getName()
  314.   return $this->name}
  315.  
  316.  
  317.  
  318.   /**
  319.    * Returns the specified port to use to connect to the host.
  320.    *
  321.    * @version 1.0
  322.    * @since   0.1.0
  323.    * @author  Daniel Plücken <daniel@debakel.net>
  324.    * @access  public
  325.    * @return  int 
  326.    */
  327.   function getPort()
  328.   return $this->port}
  329.  
  330.  
  331.  
  332.   /**
  333.    * Returns the specified user who should connect with to the host.
  334.    *
  335.    * @version 1.0
  336.    * @since   0.1.0
  337.    * @author  Daniel Plücken <daniel@debakel.net>
  338.    * @access  public
  339.    * @return  string 
  340.    */
  341.   function getUser()
  342.   return $this->user}
  343.  
  344.  
  345.  
  346.   /**
  347.    * Returns the given password which should be usedto connect to the host.
  348.    *
  349.    * @access  public
  350.    * @version 1.0
  351.    * @since   0.1.0
  352.    *
  353.    * @return  string 
  354.    */
  355.   function getPassword()
  356.   return $this->password}
  357.  
  358.  
  359.  
  360.   /**
  361.    * Returns the id of the connection resource to the database host.
  362.    *
  363.    * @access  public
  364.    * @version 1.0
  365.    * @since   0.1.44
  366.    *
  367.    * @return object 
  368.    */
  369.   function &getResourceID()
  370.   return $this->resID}
  371. // End of class ABSTDatabaseHost
  372. ?>

Documentation generated on Thu, 05 Jun 2008 19:09:38 +0200 by phpDocumentor 1.4.1