Skip to content

MySQL and MySQLi connection with custom port #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ class Shuttle_DBConn {
public $username;
public $password;
public $name;
public $port;

protected $connection;

Expand All @@ -375,6 +376,7 @@ function __construct($options) {
$this->username = $options['username'];
$this->password = $options['password'];
$this->name = $options['db_name'];
$this->port = $options['db_port'];
}

static function create($options) {
Expand All @@ -390,7 +392,7 @@ static function create($options) {

class Shuttle_DBConn_Mysql extends Shuttle_DBConn {
function connect() {
$this->connection = @mysql_connect($this->host, $this->username, $this->password);
$this->connection = @mysql_connect($this->host . ":" . $this->port, $this->username, $this->password);
if (!$this->connection) {
throw new Shuttle_Exception("Couldn't connect to the database: " . mysql_error());
}
Expand Down Expand Up @@ -452,7 +454,7 @@ function fetch_row($data) {

class Shuttle_DBConn_Mysqli extends Shuttle_DBConn {
function connect() {
$this->connection = @new MySQLi($this->host, $this->username, $this->password, $this->name);
$this->connection = @new MySQLi($this->host, $this->username, $this->password, $this->name, $this->port);

if ($this->connection->connect_error) {
throw new Shuttle_Exception("Couldn't connect to the database: " . $this->connection->connect_error);
Expand Down