Ignore:
Timestamp:
03/29/10 14:46:01 (14 years ago)
Author:
pedroerp
Message:

Ticket #609 - Merged 2197:2356 /sandbox/workflow/branches/609/ em /sandbox/workflow/trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/trunk/inc/engine/src/common/Base.php

    r2165 r2372  
    3939        var $child_name = 'Base'; 
    4040 
     41        /** 
     42         * @var object $db_shared_obj The database abstraction object shared between 
     43         *                                                    all instances of this class. 
     44         * @acess private 
     45         * @static 
     46         */ 
     47        private static $db_shared_obj = null; 
     48 
    4149  /** 
    4250   * Constructor receiving a database abstraction object 
     
    4654   * @access public 
    4755   */ 
    48   function Base(&$db) 
     56  function Base() 
    4957  { 
    50     if(!$db) { 
     58        /** 
     59         * New Stuff! 
     60         * We decided to get here the database object. In a recent past, 
     61         * all the classes that specialize this one passed a db object. 
     62         * Now, to simplify and save memory, we store the database object 
     63         * into a single and static atribute shared among each instance 
     64         * of this class. 
     65         * 
     66         * To prevent to modify all sub-classes to use "self::$db" instead 
     67         * of "this->db", we made a very tiny workaround here. In the first 
     68         * instantiation of this class, we instantiate the database object 
     69         * and store it into 'self::$db_shared_obj'. Any subsequent 
     70         * instantiations will just point to the static one. 
     71         */ 
     72        if (!self::$db_shared_obj) 
     73                self::$db_shared_obj = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
     74 
     75        $this->db = &self::$db_shared_obj; 
     76 
     77 
     78    if(!$this->db) { 
    5179      die('Invalid db object passed to '.$this->child_name.' constructor'); 
    5280    } 
    5381    //Force transactionnal mysql (Innodb) -> mysqlt 
    54     if ($db->databaseType=='mysql') 
     82    if ($this->db->databaseType=='mysql') 
    5583    { 
    5684        $GLOBALS['phpgw']->db->disconnect(); 
    57         $db = $GLOBALS['phpgw']->db->connect( 
     85        $this->db = $GLOBALS['phpgw']->db->connect( 
    5886                        $GLOBALS['phpgw_info']['server']['db_name'], 
    5987                        $GLOBALS['phpgw_info']['server']['db_host'], 
     
    6492                ); 
    6593    } 
    66     $this->db = &$db; 
    6794  } 
    6895 
Note: See TracChangeset for help on using the changeset viewer.