File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class Mysqldump
4747
4848 // This can be set both on constructor or manually
4949 public $ host ;
50+ public $ port ;
5051 public $ user ;
5152 public $ pass ;
5253 public $ db ;
@@ -120,7 +121,16 @@ public function __construct(
120121 $ this ->db = $ db ;
121122 $ this ->user = $ user ;
122123 $ this ->pass = $ pass ;
123- $ this ->host = $ host ;
124+
125+ $ colonPos = strpos ($ host , ': ' );
126+ if (false !== $ colonPos ) {
127+ $ this ->port = substr ($ host , $ colonPos + 1 );
128+ $ this ->host = substr ($ host , 0 , $ colonPos );
129+ } else {
130+ $ this ->port = null ;
131+ $ this ->host = $ host ;
132+ }
133+
124134 $ this ->dbType = strtolower ($ type );
125135 $ this ->pdoSettings = self ::array_replace_recursive ($ pdoSettingsDefault , $ pdoSettings );
126136 $ this ->dumpSettings = self ::array_replace_recursive ($ dumpSettingsDefault , $ dumpSettings );
@@ -179,9 +189,12 @@ private function connect()
179189 case 'mysql ' :
180190 case 'pgsql ' :
181191 case 'dblib ' :
192+ $ dsn = $ this ->dbType .
193+ ":host= " . $ this ->host .
194+ (isset ($ this ->port ) ? ";port= " . $ this ->port : "" ) .
195+ ";dbname= " . $ this ->db ;
182196 $ this ->dbHandler = new PDO (
183- $ this ->dbType . ":host= " .
184- $ this ->host . ";dbname= " . $ this ->db ,
197+ $ dsn ,
185198 $ this ->user ,
186199 $ this ->pass ,
187200 $ this ->pdoSettings
Original file line number Diff line number Diff line change 3333 "test001 " ,
3434 "travis " ,
3535 "" ,
36- "localhost " ,
36+ "localhost:3306 " ,
3737 "mysql " ,
3838 $ dumpSettings );
3939
You can’t perform that action at this time.
0 commit comments