Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PHP-MySQLi-Database-Class
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
PHP-MySQLi-Database-Class
Commits
ef039a5a
Commit
ef039a5a
authored
Jun 01, 2017
by
Alexander Butenko
Committed by
GitHub
Jun 01, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #627 from ilyagory/master
add socket option to mysqlidb constructor
parents
240a4fd5
8dd1a11a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
MysqliDb.php
MysqliDb.php
+12
-7
No files found.
MysqliDb.php
View file @
ef039a5a
...
...
@@ -136,6 +136,7 @@ class MysqliDb
* @var string
*/
protected
$host
;
protected
$socket
;
protected
$_username
;
protected
$_password
;
protected
$db
;
...
...
@@ -226,8 +227,9 @@ class MysqliDb
* @param string $db
* @param int $port
* @param string $charset
* @params string $socket
*/
public
function
__construct
(
$host
=
null
,
$username
=
null
,
$password
=
null
,
$db
=
null
,
$port
=
null
,
$charset
=
'utf8'
)
public
function
__construct
(
$host
=
null
,
$username
=
null
,
$password
=
null
,
$db
=
null
,
$port
=
null
,
$charset
=
'utf8'
,
$socket
=
null
)
{
$isSubQuery
=
false
;
...
...
@@ -240,15 +242,18 @@ class MysqliDb
// if host were set as mysqli socket
if
(
is_object
(
$host
))
{
$this
->
_mysqli
=
$host
;
}
else
{
$this
->
host
=
$host
;
}
}
else
// in case of using socket & host not exists in config array
if
(
is_string
(
$host
))
{
$this
->
host
=
$host
;
}
$this
->
_username
=
$username
;
$this
->
_password
=
$password
;
$this
->
db
=
$db
;
$this
->
port
=
$port
;
$this
->
charset
=
$charset
;
$this
->
socket
=
$socket
;
if
(
$isSubQuery
)
{
$this
->
isSubQuery
=
true
;
...
...
@@ -274,11 +279,11 @@ class MysqliDb
return
;
}
if
(
empty
(
$this
->
host
))
{
throw
new
Exception
(
'MySQL host is not set'
);
if
(
empty
(
$this
->
host
)
&&
empty
(
$this
->
socket
)
)
{
throw
new
Exception
(
'MySQL host
or socket
is not set'
);
}
$this
->
_mysqli
=
new
mysqli
(
$this
->
host
,
$this
->
_username
,
$this
->
_password
,
$this
->
db
,
$this
->
port
);
$this
->
_mysqli
=
new
mysqli
(
$this
->
host
,
$this
->
_username
,
$this
->
_password
,
$this
->
db
,
$this
->
port
,
$this
->
socket
);
if
(
$this
->
_mysqli
->
connect_error
)
{
throw
new
Exception
(
'Connect Error '
.
$this
->
_mysqli
->
connect_errno
.
': '
.
$this
->
_mysqli
->
connect_error
,
$this
->
_mysqli
->
connect_errno
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment