Show
Ignore:
Timestamp:
01/11/06 16:00:15 (6 years ago)
Author:
john
Message:

added to AR database_name and force_reconnect vars

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/active_record.php

    r110 r112  
    2828class ActiveRecord { 
    2929 
    30     static private $db = null;              # Reference to Pear db object 
    31     static protected $inflector = null;     # object to do class inflection 
    32     public $content_columns = null;         # info about each column in the table 
    33     public $table_name = null; 
     30    static private $db = null; # Reference to Pear db object 
     31    static protected $inflector = null; # object to do class inflection 
     32    public $content_columns = null; # info about each column in the table 
     33    public $table_name = null; # if you want to override table name set this in your model 
     34    public $database_name = null; # if you want to override database name set this in your model 
    3435    public $fetch_mode = DB_FETCHMODE_ASSOC; 
     36    public $force_reconnect = false; # should we force a connection everytime 
    3537 
    3638    # Table associations 
     
    994996    function establish_connection() { 
    995997        # Connect to the database and throw an error if the connect fails. 
    996         if(!is_object($GLOBALS['ACTIVE_RECORD_DB'])) { 
     998        if(!is_object($GLOBALS['ACTIVE_RECORD_DB']) || $this->force_reconnect) { 
    997999            if(array_key_exists("use", $GLOBALS['TRAX_DB_SETTINGS'][TRAX_MODE])) { 
    9981000                $connection_settings = $GLOBALS['TRAX_DB_SETTINGS'][$GLOBALS['TRAX_DB_SETTINGS'][TRAX_MODE]['use']]; 
     
    10001002                $connection_settings = $GLOBALS['TRAX_DB_SETTINGS'][TRAX_MODE]; 
    10011003            } 
     1004            # Override database name if param is set 
     1005            if($this->database_name) { 
     1006                $connection_settings['database'] = $this->database_name;                
     1007            }             
    10021008            # Set optional Pear parameters 
    10031009            if(isset($connection_settings['persistent'])) {