Changeset 3138

Show
Ignore:
Timestamp:
04/29/08 08:55:49 (2 months ago)
Author:
pmjones
Message:

Solar_Sql_Adapter(_Mysql): [ADD] Per talk w/James Kilbride, adding 'sock' config key to specify the Unix socket. The Mysql adapter now honors it as well.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Solar/Sql/Adapter.php

    r3112 r3138  
    5050     * : (string) Port number for the host name. 
    5151     *  
     52     * `sock` 
     53     * : (string) The Unix socket for the connection. Should not be used with 
     54     *   host and port. 
     55     *  
    5256     * `user` 
    5357     * : (string) Connect to the database as this username. 
     
    6872        'host'      => null, 
    6973        'port'      => null, 
     74        'sock'      => null, 
    7075        'user'      => null, 
    7176        'pass'      => null, 
  • trunk/Solar/Sql/Adapter/Mysql.php

    r2933 r3138  
    9595    protected $_pdo_type = 'mysql'; 
    9696     
     97    /** 
     98     *  
     99     * Creates a PDO-style DSN. 
     100     *  
     101     * For example, "mysql:host=127.0.0.1;dbname=test" 
     102     *  
     103     * @return string A PDO-style DSN. 
     104     *  
     105     */ 
     106    protected function _dsn() 
     107    { 
     108        $dsn = array(); 
     109         
     110        // socket, or host-and-port? (can't use both.) 
     111        if (! empty($this->_config['sock'])) { 
     112             
     113            // use a socket 
     114            $dsn[] = 'unix_socket=' . $this->_config['sock']; 
     115             
     116        } else { 
     117             
     118            // use host and port 
     119            if (! empty($this->_config['host'])) { 
     120                $dsn[] = 'host=' . $this->_config['host']; 
     121            } 
     122         
     123            if (! empty($this->_config['port'])) { 
     124                $dsn[] = 'port=' . $this->_config['port']; 
     125            } 
     126             
     127        } 
     128         
     129        // database name 
     130        if (! empty($this->_config['name'])) { 
     131            $dsn[] = 'dbname=' . $this->_config['name']; 
     132        } 
     133         
     134        return $this->_pdo_type . ':' . implode(';', $dsn); 
     135    } 
     136     
     137     
     138 
    97139    /** 
    98140     *