Skip to content

Commit 5977434

Browse files
committed
fix prepare statement mysqli
1 parent 4fca7e6 commit 5977434

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

system/Database/MySQLi/PreparedQuery.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,19 @@ public function _execute(array $data): bool
6666
throw new BadMethodCallException('You must call prepare before trying to execute a prepared statement.');
6767
}
6868

69-
// First off -bind the parameters
70-
$bindTypes = '';
69+
// First off - bind the parameters
70+
$bindTypes = '';
71+
$binaryData = [];
7172

7273
// Determine the type string
73-
foreach ($data as $item) {
74+
foreach ($data as $key => $item) {
7475
if (is_int($item)) {
7576
$bindTypes .= 'i';
7677
} elseif (is_numeric($item)) {
7778
$bindTypes .= 'd';
79+
} elseif (is_string($item) && $this->isBinary($item)) {
80+
$bindTypes .= 'b';
81+
$binaryData[$key] = $item;
7882
} else {
7983
$bindTypes .= 's';
8084
}
@@ -83,6 +87,11 @@ public function _execute(array $data): bool
8387
// Bind it
8488
$this->statement->bind_param($bindTypes, ...$data);
8589

90+
// Stream binary data
91+
foreach ($binaryData as $key => $value) {
92+
$this->statement->send_long_data($key, $value);
93+
}
94+
8695
try {
8796
return $this->statement->execute();
8897
} catch (mysqli_sql_exception $e) {

0 commit comments

Comments
 (0)