diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-07-19 22:11:04 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-07-19 22:11:04 +0000 |
commit | 84916ad9c7db5c346585ea16b23353389cacdfcf (patch) | |
tree | 336958b9c923e46909bd116068d56fbcb47057ec /includes/database/pgsql | |
parent | 659554537834bcebfe4b365b62b3a81461b93f51 (diff) | |
download | brdo-84916ad9c7db5c346585ea16b23353389cacdfcf.tar.gz brdo-84916ad9c7db5c346585ea16b23353389cacdfcf.tar.bz2 |
- Patch #845846 by Stevel, bellHead: PDOStatement::bindParam() bind to a reference even for OUT parameters.
Diffstat (limited to 'includes/database/pgsql')
-rw-r--r-- | includes/database/pgsql/query.inc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/includes/database/pgsql/query.inc b/includes/database/pgsql/query.inc index cb1b94ba2..d4a888729 100644 --- a/includes/database/pgsql/query.inc +++ b/includes/database/pgsql/query.inc @@ -27,7 +27,7 @@ class InsertQuery_pgsql extends InsertQuery { $max_placeholder = 0; $blobs = array(); $blob_count = 0; - foreach ($this->insertValues as &$insert_values) { + foreach ($this->insertValues as $insert_values) { foreach ($this->insertFields as $idx => $field) { if (isset($table_information->blob_fields[$field])) { $blobs[$blob_count] = fopen('php://memory', 'a'); @@ -45,8 +45,13 @@ class InsertQuery_pgsql extends InsertQuery { } } if (!empty($this->fromQuery)) { - foreach ($this->fromQuery->getArguments() as $key => $value) { - $stmt->bindParam($key, $value); + // bindParam stores only a reference to the variable that is followed when + // the statement is executed. We pass $arguments[$key] instead of $value + // because the second argument to bindParam is passed by reference and + // the foreach statement assigns the element to the existing reference. + $arguments = $this->fromQuery->getArguments(); + foreach ($arguments as $key => $value) { + $stmt->bindParam($key, $arguments[$key]); } } @@ -138,13 +143,13 @@ class UpdateQuery_pgsql extends UpdateQuery { // We assume that an expression will never happen on a BLOB field, // which is a fairly safe assumption to make since in most cases // it would be an invalid query anyway. - $stmt->bindParam($placeholder, $argument); + $stmt->bindParam($placeholder, $data['arguments'][$placeholder]); } } unset($fields[$field]); } - foreach ($fields as $field => &$value) { + foreach ($fields as $field => $value) { $placeholder = ':db_update_placeholder_' . ($max_placeholder++); if (isset($table_information->blob_fields[$field])) { @@ -155,7 +160,7 @@ class UpdateQuery_pgsql extends UpdateQuery { ++$blob_count; } else { - $stmt->bindParam($placeholder, $value); + $stmt->bindParam($placeholder, $fields[$field]); } } @@ -163,8 +168,8 @@ class UpdateQuery_pgsql extends UpdateQuery { $this->condition->compile($this->connection, $this); $arguments = $this->condition->arguments(); - foreach ($arguments as $placeholder => &$value) { - $stmt->bindParam($placeholder, $value); + foreach ($arguments as $placeholder => $value) { + $stmt->bindParam($placeholder, $arguments[$placeholder]); } } |