Changeset 832

Show
Ignore:
Timestamp:
10/16/2007 07:01:30 AM (14 months ago)
Author:
Geert
Message:
  • Reordering Database constructor a bit
  • Optimized unix socket regex
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Database.php

    r828 r832  
    6363         * 
    6464         * @access  public 
    65          * @param   array 
     65         * @param   mixed 
    6666         * @return  void 
    6767         */ 
     
    7575                elseif (is_string($config)) 
    7676                { 
    77                         // Group namd 
    78                         $name = $config; 
    79  
    80                         // This checks to see if the config is DSN string, or a config group name 
    81                         if (strpos($config, '://') === FALSE) 
    82                         { 
    83                                 $name = $config; 
    84  
    85                                 // Test the config group name 
    86                                 if (($config = Config::item('database.'.$config)) === FALSE) 
    87                                 { 
    88                                         throw new Kohana_Database_Exception('database.undefined_group', $name); 
    89                                 } 
    90                         } 
    91                         else 
     77                        // The config is a DSN string 
     78                        if (strpos($config, '://') !== FALSE) 
    9279                        { 
    9380                                $config = array('connection' => $config); 
    9481                        } 
     82                        // The config is a group name 
     83                        else 
     84                        { 
     85                                $name = $config; 
     86                                 
     87                                // Test the config group name 
     88                                if (($config = Config::item('database.'.$config)) === FALSE) 
     89                                        throw new Kohana_Database_Exception('database.undefined_group', $name); 
     90                        } 
    9591                } 
    9692 
     
    10096                // Make sure the connection is valid 
    10197                if (strpos($this->config['connection'], '://') === FALSE) 
    102                 { 
    10398                        throw new Kohana_Exception('database.invalid_dsn', $this->config['connection']); 
    104                 } 
    10599 
    106100                // Parse the DSN, creating an array to hold the connection parameters 
     
    135129 
    136130                        // Find the socket 
    137                         if (preg_match('/^unix\(.+\)/', $connection)) 
     131                        if (preg_match('/^unix\([^)]++\)/', $connection)) 
    138132                        { 
    139133                                // This one is a little hairy: we explode based on the end of