Skip to content

expand the appropriate database extension classes to include port/socket options #31

@csurf

Description

@csurf

the mysql* classes currently only try to make connections with the basic/minimum parameters (username, password, dbname) and passing additional parameters such as host, port/socket,etc. through the dsn doesnt work because the extra parameters are simply ignored; they are never passed through to the 'mysql*_connect()' function.

my hacked solution to this was:
-make the following change in the 'Factory' _parseDsn method
@ around line 93:
// $server['dsn'] = 'mysql:dbname=' . $schema . ';host=' . $server['host'];
$server['dsn']=$dsn;
*this should allow the full dsn to be passed through & parsed, and the necessary values be populated in the query class.

-add additional properties to the 'Mysql' class
protected $_port;
protected $_socket;

-add the following to the 'Mysql' constructor
$this->_port = (isset($dsn['port']))?$dsn['port']:null;
$this->_socket = (isset($dsn['socket']))?$dsn['socket']:'';

-make the following change in the Mysql & Mysqli 'prepare' function
if ($this->_link === null) {
$this->_link = mysqli_connect($this->_host, $this->_user, $this->_password,$this->_dbname,$this->_port,$this->_socket);
*this will allow custom connections to a mysql server (either via tcp or a custom socket)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions