Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
afi
zf
Commits
8ebe9ed4
Commit
8ebe9ed4
authored
Oct 08, 2014
by
Patrick Barroca
😁
Browse files
Mysqli connection can set native float and int option when mysqlnd is used
parent
78ee5819
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
+33
-15
library/Zend/Db/Adapter/Mysqli.php
library/Zend/Db/Adapter/Mysqli.php
+33
-15
No files found.
library/Zend/Db/Adapter/Mysqli.php
View file @
8ebe9ed4
...
@@ -291,21 +291,11 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
...
@@ -291,21 +291,11 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
throw
new
Zend_Db_Adapter_Mysqli_Exception
(
'The Mysqli extension is required for this adapter but the extension is not loaded'
);
throw
new
Zend_Db_Adapter_Mysqli_Exception
(
'The Mysqli extension is required for this adapter but the extension is not loaded'
);
}
}
if
(
isset
(
$this
->
_config
[
'port'
]))
{
// suppress connections warning, will be handled by exception thrown
$port
=
(
integer
)
$this
->
_config
[
'port'
];
@
$this
->
_connectWithDetection
((
isset
(
$this
->
_config
[
'port'
]))
}
else
{
?
(
integer
)
$this
->
_config
[
'port'
]
$port
=
null
;
:
null
);
}
// Suppress connection warnings here.
// Throw an exception instead.
@
$this
->
_connection
=
new
mysqli
(
$this
->
_config
[
'host'
],
$this
->
_config
[
'username'
],
$this
->
_config
[
'password'
],
$this
->
_config
[
'dbname'
],
$port
);
if
(
$this
->
_connection
===
false
||
mysqli_connect_errno
())
{
if
(
$this
->
_connection
===
false
||
mysqli_connect_errno
())
{
/**
/**
* @see Zend_Db_Adapter_Mysqli_Exception
* @see Zend_Db_Adapter_Mysqli_Exception
...
@@ -315,6 +305,34 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
...
@@ -315,6 +305,34 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
}
}
}
}
protected
function
_connectWithDetection
(
$port
)
{
if
(
!
function_exists
(
'mysqli_get_client_stats'
))
{
$this
->
_legacyConnect
(
$port
);
return
;
}
// when we use mysqlnd, we can ensure same native datatype in prepared statement and in simple queries
$this
->
_connection
=
mysqli_init
();
$this
->
_connection
->
options
(
MYSQLI_OPT_INT_AND_FLOAT_NATIVE
,
1
);
$this
->
_connection
->
real_connect
(
$this
->
_config
[
'host'
],
$this
->
_config
[
'username'
],
$this
->
_config
[
'password'
],
$this
->
_config
[
'dbname'
],
$port
);
}
protected
function
_legacyConnect
(
$port
)
{
$this
->
_connection
=
new
mysqli
(
$this
->
_config
[
'host'
],
$this
->
_config
[
'username'
],
$this
->
_config
[
'password'
],
$this
->
_config
[
'dbname'
],
$port
);
}
/**
/**
* Force the connection to close.
* Force the connection to close.
*
*
...
@@ -493,4 +511,4 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
...
@@ -493,4 +511,4 @@ class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
}
}
}
}
}
}
\ No newline at end of file
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