Skip to content

Commit

Permalink
Fix streams with PostgreSQL (Request #10805).
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Feb 6, 2017
1 parent 8867906 commit 5c2ec0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php
Expand Up @@ -262,6 +262,7 @@ protected function _executePrepared($sql, $values, $binary_values)
try {
$stmt = $this->_connection->prepare($query);
foreach ($binary_values as $key => $bvalue) {
rewind($bvalue);
$stmt->bindParam(':binary' . $key, $bvalue, PDO::PARAM_LOB);
}
} catch (PDOException $e) {
Expand Down Expand Up @@ -311,7 +312,8 @@ public function insertBlob($table, $fields, $pk = null, $idValue = null)
$placeholders = $values = $binary = array();
$binary_cnt = 0;
foreach ($fields as $name => $value) {
if ($value instanceof Horde_Db_Value) {
if (is_object($value) &&
get_class($value) == 'Horde_Db_Value_Binary') {
$placeholders[] = ':binary' . $binary_cnt++;
$binary[] = $value->stream;
} else {
Expand Down
1 change: 1 addition & 0 deletions framework/Db/lib/Horde/Db/Adapter/Postgresql/Column.php
Expand Up @@ -172,6 +172,7 @@ protected function _extractValueFromDefault($default)
public function binaryToString($value)
{
if (is_resource($value)) {
rewind($value);
$string = stream_get_contents($value);
fclose($value);
return $string;
Expand Down

0 comments on commit 5c2ec0d

Please sign in to comment.