Skip to content

Commit

Permalink
make oci8 happy - hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Dec 23, 2024
1 parent 24c2422 commit ab91936
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions system/Database/OCI8/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,20 @@ public function _execute(array $data): bool
throw new BadMethodCallException('You must call prepare before trying to execute a prepared statement.');
}

$binaryData = [];

foreach ($data as $key => $item) {
if (is_string($item) && $this->isBinary($item)) {
$binaryData[$key] = oci_new_descriptor($this->db->connID, OCI_D_LOB);
oci_bind_by_name($this->statement, ':' . $key, $binaryData[$key], -1, OCI_B_BLOB);
foreach (array_keys($data) as $key) {
if (is_string($data[$key]) && $this->isBinary($data[$key])) {
$binaryData = oci_new_descriptor($this->db->connID, OCI_D_LOB);
$binaryData->writeTemporary($data[$key], OCI_TEMP_BLOB);
oci_bind_by_name($this->statement, ':' . $key, $binaryData, -1, OCI_B_BLOB);
} else {
oci_bind_by_name($this->statement, ':' . $key, $item);
oci_bind_by_name($this->statement, ':' . $key, $data[$key]);
}
}

$result = oci_execute(
$this->statement,
$binaryData === [] ? $this->db->commitMode : OCI_NO_AUTO_COMMIT
);

if ($binaryData !== []) {
foreach ($binaryData as $key => $blob) {
if (! $blob->save($data[$key])) {
oci_rollback($this->db->connID);

return false;
}
}

oci_commit($this->db->connID);
$result = oci_execute($this->statement, $this->db->commitMode);

foreach ($binaryData as $blob) {
$blob->free();
}
if (isset($binaryData)) {
$binaryData->free();
}

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

0 comments on commit ab91936

Please sign in to comment.