Check for floats and enable native prepares
This commit is contained in:
parent
5656c0564a
commit
261d7435c0
1 changed files with 9 additions and 1 deletions
|
@ -76,6 +76,8 @@ class dba {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
self::$db = @new PDO($connect, $user, $pass);
|
self::$db = @new PDO($connect, $user, $pass);
|
||||||
|
self::$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||||
|
self::$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
|
||||||
self::$connected = true;
|
self::$connected = true;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
}
|
}
|
||||||
|
@ -1298,12 +1300,18 @@ class dba {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
// Check if there are integer values in the parameters
|
// Check if there are integer values in the parameters
|
||||||
$is_int = false;
|
$is_int = false;
|
||||||
|
$is_float = false;
|
||||||
$is_alpha = false;
|
$is_alpha = false;
|
||||||
foreach ($value as $single_value) {
|
foreach ($value as $single_value) {
|
||||||
if (is_int($single_value)) {
|
if (is_int($single_value)) {
|
||||||
$is_int = true;
|
$is_int = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To prevent to round floats we look for them
|
||||||
|
if (is_float($single_value)) {
|
||||||
|
$is_float = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Is any non numeric value present?
|
// Is any non numeric value present?
|
||||||
if (!is_numeric($single_value)) {
|
if (!is_numeric($single_value)) {
|
||||||
$is_alpha = true;
|
$is_alpha = true;
|
||||||
|
@ -1314,7 +1322,7 @@ class dba {
|
||||||
if ($is_int) {
|
if ($is_int) {
|
||||||
$casted = [];
|
$casted = [];
|
||||||
foreach ($value as $single_value) {
|
foreach ($value as $single_value) {
|
||||||
if (!$is_alpha) {
|
if (!$is_alpha && !$is_float) {
|
||||||
$casted[] = (int)$single_value;
|
$casted[] = (int)$single_value;
|
||||||
} else {
|
} else {
|
||||||
$casted[] = (string)$single_value;
|
$casted[] = (string)$single_value;
|
||||||
|
|
Loading…
Reference in a new issue