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

Source for file ABSTView.class.php

Documentation is available at ABSTView.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.  
  11. /**
  12.  *
  13.  */
  14. include_onceCLASSPATH."core/PlainTextFormatter.class.php" );
  15.  
  16. /**
  17.  * @package   databases
  18.  * @version   0.1.53
  19.  * @author    Daniel Plücken <daniel@debakel.net>
  20.  * @license   http://www.gnu.org/copyleft/lesser.html
  21.  *             GNU Lesser General Public License
  22.  * @copyright Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>
  23.  *
  24.  *  This library is free software; you can redistribute it and/or
  25.  *  modify it under the terms of the GNU Lesser General Public
  26.  *  License as published by the Free Software Foundation; either
  27.  *  version 2.1 of the License.
  28.  *
  29.  *  This library is distributed in the hope that it will be useful,
  30.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  31.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32.  *  GNU Lesser General Public License for more details.
  33.  *
  34.  *  You should have received a copy of the GNU Lesser General
  35.  *  Public License along with this library; if not, write to the
  36.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  37.  *  Boston, MA 02111-1307 USA
  38.  */
  39. class ABSTView
  40. {
  41.   /**
  42.    * The name of this view.
  43.    *
  44.    * @var    string  $name 
  45.    * @access private
  46.    */
  47.   var $name;
  48.   /**
  49.    * Array for carrying the joins included in this view.
  50.    *
  51.    * @var    array   $join 
  52.    * @access private
  53.    */
  54.   var $join;
  55.   /**
  56.    * The last stored databasequery.
  57.    *
  58.    * @var    string $last_query 
  59.    * @access public
  60.    */
  61.   var $last_query = "&lt;empty&gt;";
  62.   /**
  63.    * This stores the additionally fields for the result list of the query.
  64.    *
  65.    * @var    string $custom_field_arr 
  66.    * @access public
  67.    */
  68.   var $custom_field_arr = array();
  69.   /**
  70.    * Carries the name of a function which has to be invoked on a connection
  71.    * error.
  72.    *
  73.    * @access public
  74.    * @var    function $error_callback 
  75.    */
  76.   var $error_callback = null;
  77.  
  78.  
  79.  
  80.   /**
  81.    * Fake-Constructor
  82.    *
  83.    * @version 1.0
  84.    * @since   0.1.3
  85.    * @author  Daniel Plücken <daniel@debakel.net>
  86.    * @access  public
  87.    */
  88.   function ABSTView()
  89.   {
  90.     echo "<h3>This is an abstract class. "
  91.             ."You cannot get an instance of it!</h3>";
  92.     exit();
  93.   }
  94.  
  95.  
  96.  
  97.   /**
  98.    * Sets the name of the function that should be invoked on a connection error.
  99.    * The function to call back has to have two parameter. The first parameter is
  100.    * for the error code. The second one contains the errordescription.
  101.    *
  102.    * @version 1.0
  103.    * @since   0.1.52
  104.    * @author  Daniel Plücken <daniel@debakel.net>
  105.    * @access  public
  106.    * @param   string $function_name_str 
  107.    * @return  void 
  108.    */
  109.   function setErrorCallback$function_name_str )
  110.   $this->error_callback = $function_name_str}
  111.  
  112.  
  113.  
  114.   /**
  115.    * Constructor
  116.    *
  117.    * @version 1.0
  118.    * @since   0.1.0
  119.    * @author  Daniel Plücken <daniel@debakel.net>
  120.    * @access  public
  121.    * @param   string  $name 
  122.    * @return  ABSTView 
  123.    */
  124.   function __constructor$name )
  125.   {
  126.     if!empty$name ) )
  127.       $this->name;
  128.     else
  129.       die(
  130.            "<h3>You have to give a name to this database view!</h3>"
  131.           ."<b>Use following Syntax:<b><br><br>\r\n"
  132.           ."<pre>\r\n"
  133.           ."  \x24db_view = new View( \x24name );\r\n"
  134.           ."</pre>\r\n"
  135.          );
  136.   }
  137.  
  138.  
  139.  
  140.   /**
  141.    * Returns the name of this view.
  142.    *
  143.    * @version 1.0
  144.    * @since   0.1.0
  145.    * @author  Daniel Plücken <daniel@debakel.net>
  146.    * @access  public
  147.    * @return  string 
  148.    */
  149.   function getName()
  150.   return $this->name}
  151.  
  152.  
  153.  
  154.   /**
  155.    * Returns the last stored database query.
  156.    *
  157.    * @version 1.0
  158.    * @since   0.1.2
  159.    * @author  Daniel Plücken <daniel@debakel.net>
  160.    * @access  public
  161.    * @return  string 
  162.    */
  163.   function getLastQuery()
  164.   return PlainTextFormatter::formatSQL$this->last_query )}
  165.  
  166.  
  167.  
  168.   /**
  169.    * Sets additionally fields to the definition of the result list of the query.
  170.    *
  171.    * @version 1.0
  172.    * @since   0.1.5
  173.    * @author  Daniel Plücken <daniel@debakel.net>
  174.    * @access  public
  175.    * @param   array  $array 
  176.    * @return  void 
  177.    */
  178.   function setCustomFields$array )
  179.   {
  180.     if!is_array$array ) )
  181.       $this->addCustomField$array );
  182.  
  183.     $this->custom_field_arr = $array;
  184.   }
  185.  
  186.  
  187.  
  188.   /**
  189.    * This can be use to add a field to the definition of the result list of the
  190.    * query.
  191.    *
  192.    * @version 1.0
  193.    * @since   0.1.5
  194.    * @author  Daniel Plücken <daniel@debakel.net>
  195.    * @access  public
  196.    * @param   string  $string 
  197.    * @return  void 
  198.    */
  199.   function addCustomField$string )
  200.   $this->custom_field_arr[$string}
  201.  
  202.  
  203.  
  204.   /**
  205.    * Adds a join's reference to this view's object.
  206.    *
  207.    * @version 1.0
  208.    * @since   0.1.2
  209.    * @author  Daniel Plücken <daniel@debakel.net>
  210.    * @access  public
  211.    * @param   Join   $obj_ref 
  212.    *  return   void
  213.    */
  214.   function addJoin&$obj_ref )
  215.   {
  216.     if(
  217.         is_a$obj_ref"Join" )
  218.      || is_subclass_of$obj_ref"Join" )
  219.       )
  220.       $this->join[$obj_ref;
  221.     else
  222.       die(
  223.            "<h3>The given parameter refers not to a valid object of a "
  224.           ."join.</h3>"
  225.          );
  226.   }
  227.  
  228.  
  229.   /**
  230.    * Returns the datasets as an two dimensional array if the query could be
  231.    * execute. The first dimension carries the datasets. The second dimension
  232.    * carries the fields's values of the result list.
  233.    *
  234.    * Usage:
  235.    *          getDatasetsWithFields( $fieldnamesArr, $where );
  236.    *
  237.    * @version 1.0
  238.    * @since   0.1.4
  239.    * @author  Daniel Plücken <daniel@debakel.net>
  240.    * @access  public
  241.    * @param   array  $fields  Is a blind parameter whithout any funktion.
  242.    * @param   string $where   The where clause of the query.
  243.    * @return  array 
  244.    */
  245.   function getDatasetsWithFields$fields ""$where "" )
  246.   return $this->getDatasets$where )}
  247.  
  248.  
  249.  
  250.   /**
  251.    * Returns the id of the connection resource to the database host.
  252.    *
  253.    * @access  public
  254.    * @version 1.0
  255.    * @since   0.1.53
  256.    *
  257.    * @return object 
  258.    */
  259.   function &getResourceID()
  260.   return $this->join[0]->dbt_left->getResourceID()}
  261. // End of class ABSTView
  262. ?>

Documentation generated on Thu, 05 Jun 2008 19:10:03 +0200 by phpDocumentor 1.4.1