Changeset 273 for trunk/trax/vendor

Show
Ignore:
Timestamp:
01/21/07 21:58:59 (5 years ago)
Author:
john
Message:

added schema_search_path to AR for postgres schemas

Files:
1 modified

Legend:

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

    r272 r273  
    8080     *  <p>Retrieved from the RDBMS by {@link set_content_columns()}. 
    8181     *  See {@link  
    82      *  http://pear.php.net/manual/en/package.database.db.db-common.tableinfo.php 
     82     *  http://pear.php.net/package/MDB2/docs/2.3.0/MDB2/MDB2_Driver_Reverse_Common.html#methodtableInfo 
    8383     *  DB_common::tableInfo()} for the format.  <b>NOTE:</b> Some 
    8484     *  RDBMS's don't return all values.</p> 
     
    164164     * Stores the active connections. Indexed on $connection_name. 
    165165     */ 
    166     public static $active_connections = array(); 
     166    protected static $active_connections = array(); 
    167167 
    168168    /** 
     
    170170     * 
    171171     *  See {@link 
    172      *  http://pear.php.net/manual/en/package.database.db.db-common.setfetchmode.php 
    173      *  the relevant PEAR DB class documentation} 
     172     *  http://pear.php.net/package/MDB2/docs/2.3.0/MDB2/MDB2_Driver_Common.html#methodsetFetchMode 
     173     *  the relevant PEAR MDB2 class documentation} 
    174174     *  @var integer 
    175175     */ 
     
    241241     
    242242    /** 
    243      *  @todo Document this property 
     243     *  Whether or not to auto save defined associations if set 
    244244     *  @var boolean 
    245245     */ 
    246     public $auto_save_associations = true; # where or not to auto save defined associations if set 
     246    public $auto_save_associations = true; 
    247247 
    248248    /** 
     
    342342 
    343343    /** 
    344      *  @todo Document this variable 
    345      */ 
    346     public $display = 10; # Pagination how many numbers in the list << < 1 2 3 4 > >> 
     344     *  Pagination how many numbers in the list << < 1 2 3 4 > >> 
     345     */ 
     346    public $display = 10; 
    347347 
    348348    /** 
     
    401401        'validates_uniqueness_of' 
    402402    ); 
    403      
    404     /** 
    405      * An array of all the builtin validation function to validate on a save/create/update. 
    406      */       
    407     public $builtins_to_validate = array(); 
    408403 
    409404    /** 
     
    417412 
    418413    /** 
    419      *  @todo Document this variable 
    420      */ 
    421     public $auto_save_habtm = true; # auto insert / update $has_and_belongs_to_many tables 
    422  
    423     /** 
    424      *  @todo Document this variable 
     414     *  Auto insert / update $has_and_belongs_to_many tables 
     415     */ 
     416    public $auto_save_habtm = true; 
     417 
     418    /** 
     419     *  Auto delete $has_and_belongs_to_many associations 
    425420     */     
    426     public $auto_delete_habtm = true; # auto delete $has_and_belongs_to_many associations 
     421    public $auto_delete_habtm = true;  
    427422 
    428423    /** 
    429424     *  Transactions (only use if your db supports it) 
    430      */ 
    431     private static $begin_executed = false; # this is for transactions only to let query() know that a 'BEGIN' has been executed 
     425     *  This is for transactions only to let query() know that a 'BEGIN' has been executed 
     426     */ 
     427    private static $begin_executed = false; 
    432428 
    433429    /** 
    434430     *  Transactions (only use if your db supports it) 
    435      */ 
    436     public static $use_transactions = false; # this will issue a rollback command if any sql fails 
     431     *  This will issue a rollback command if any sql fails. 
     432     */ 
     433    public static $use_transactions = false;  
    437434     
    438435    /** 
     
    25332530            $connection =& MDB2::Connect($connection_settings, $connection_options); 
    25342531            //static $connect_cnt;  $connect_cnt++; error_log("connection #".$connect_cnt); 
     2532             
     2533            # For Postgres schemas (http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html) 
     2534            if(isset($connection_settings['schema_search_path'])){ 
     2535                if(!$this->is_error($connection)) { 
     2536                    # Set the schema search path to a string of comma-separated schema names. 
     2537                    # First strip out all the whitespace 
     2538                    self::$connection->query('SET search_path TO '.preg_replace('/\s+/', '', $connection_settings['schema_search_path'])); 
     2539                } 
     2540            }  
    25352541        } 
    25362542        if(!$this->is_error($connection)) { 
    25372543            self::$active_connections[$this->connection_name] =& $connection; 
    25382544            self::$db =& $connection; 
     2545            self::$db->setFetchMode($this->fetch_mode); 
    25392546        } else { 
    25402547            $this->raise($connection->getMessage()); 
    2541         } 
    2542         self::$db->setFetchMode($this->fetch_mode); 
     2548        }       
    25432549        return self::$db; 
    25442550    }