Skip to content

Commit ab91936

Browse files
committed
make oci8 happy - hopefully
1 parent 24c2422 commit ab91936

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

system/Database/OCI8/PreparedQuery.php

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,36 +73,20 @@ public function _execute(array $data): bool
7373
throw new BadMethodCallException('You must call prepare before trying to execute a prepared statement.');
7474
}
7575

76-
$binaryData = [];
77-
78-
foreach ($data as $key => $item) {
79-
if (is_string($item) && $this->isBinary($item)) {
80-
$binaryData[$key] = oci_new_descriptor($this->db->connID, OCI_D_LOB);
81-
oci_bind_by_name($this->statement, ':' . $key, $binaryData[$key], -1, OCI_B_BLOB);
76+
foreach (array_keys($data) as $key) {
77+
if (is_string($data[$key]) && $this->isBinary($data[$key])) {
78+
$binaryData = oci_new_descriptor($this->db->connID, OCI_D_LOB);
79+
$binaryData->writeTemporary($data[$key], OCI_TEMP_BLOB);
80+
oci_bind_by_name($this->statement, ':' . $key, $binaryData, -1, OCI_B_BLOB);
8281
} else {
83-
oci_bind_by_name($this->statement, ':' . $key, $item);
82+
oci_bind_by_name($this->statement, ':' . $key, $data[$key]);
8483
}
8584
}
8685

87-
$result = oci_execute(
88-
$this->statement,
89-
$binaryData === [] ? $this->db->commitMode : OCI_NO_AUTO_COMMIT
90-
);
91-
92-
if ($binaryData !== []) {
93-
foreach ($binaryData as $key => $blob) {
94-
if (! $blob->save($data[$key])) {
95-
oci_rollback($this->db->connID);
96-
97-
return false;
98-
}
99-
}
100-
101-
oci_commit($this->db->connID);
86+
$result = oci_execute($this->statement, $this->db->commitMode);
10287

103-
foreach ($binaryData as $blob) {
104-
$blob->free();
105-
}
88+
if (isset($binaryData)) {
89+
$binaryData->free();
10690
}
10791

10892
if ($result && $this->lastInsertTableName !== '') {

0 commit comments

Comments
 (0)