Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 67 → Rev 68

/trunk/Db/MySQLDB.php
11,6 → 11,18
protected $_host;
 
/**
* Database port on the host
* @var int
*/
protected $_port;
 
/**
* MySQL Unix socket (shouldn't be used with host or port).
* @var string
*/
protected $_unix_socket;
 
/**
* Database name
* @var string
*/
48,9 → 60,20
 
public function __construct()
{
$this->readConfig();
$dbconfig = $this->readConfig();
if ($dbconfig === false)
{
return;
}
 
if (isset($dbconfig['unix_socket']))
{
$this->_unix_socket = $dbconfig['unix_socket'];
}
 
$this->_dsn = "mysql:host={$this->_host}"
. (!is_null($this->_port) ? ";port={$this->_port}" : '')
. (!is_null($this->_unix_socket) ? ";unix_socket={$this->_unix_socket}" : '')
. (!is_null($this->_dbname) ? ";dbname={$this->_dbname}" : '')
. (!is_null($this->_charset) ? ";charset={$this->_charset}" : '');
 
/trunk/Db/Database.php
152,9 → 152,9
* were set. That is, definitions in the class file
* override those in the configuration file.
*
* @return boolean|array
* <code>true</code> if the configuration
* file could be read, the configuration array otherwise.
* @return array|boolean
* The configuration array if the configuration
* file could be read, <code>false</code> otherwise.
*/
public function readConfig ()
{
165,7 → 165,11
if (isset($config[$section]))
{
$dbconfig = $config[$section];
foreach (array('host', 'dbname', 'username', 'password', 'charset') as $key)
$options = array(
'host', 'port', 'dbname', 'username', 'password', 'charset'
);
 
foreach ($options as $key)
{
$property = "_$key";
if (isset($dbconfig[$key])
176,6 → 180,8
$this->$property = $dbconfig[$key];
}
}
 
return $config[$section];
}
}