summaryrefslogtreecommitdiff
path: root/includes/database/pgsql
diff options
context:
space:
mode:
Diffstat (limited to 'includes/database/pgsql')
-rw-r--r--includes/database/pgsql/query.inc21
1 files changed, 8 insertions, 13 deletions
diff --git a/includes/database/pgsql/query.inc b/includes/database/pgsql/query.inc
index 489d57e65..ab16a70ec 100644
--- a/includes/database/pgsql/query.inc
+++ b/includes/database/pgsql/query.inc
@@ -15,19 +15,7 @@
class InsertQuery_pgsql extends InsertQuery {
public function execute() {
-
- // Confirm that the user did not try to specify an identical
- // field and default field.
- if (array_intersect($this->insertFields, $this->defaultFields)) {
- throw new PDOException('You may not specify the same field to have a value and a schema-default value.');
- }
-
- if (count($this->insertFields) + count($this->defaultFields) == 0 && empty($this->fromQuery)) {
- return NULL;
- }
-
- // Don't execute query without values.
- if (!isset($this->insertValues[0]) && count($this->insertFields) > 0 && empty($this->fromQuery)) {
+ if (!$this->preExecute()) {
return NULL;
}
@@ -56,6 +44,11 @@ class InsertQuery_pgsql extends InsertQuery {
}
}
}
+ if (!empty($this->fromQuery)) {
+ foreach ($this->fromQuery->getArguments() as $key => $value) {
+ $stmt->bindParam($key, $value);
+ }
+ }
// PostgreSQL requires the table name to be specified explicitly
// when requesting the last insert ID, so we pass that in via
@@ -82,6 +75,8 @@ class InsertQuery_pgsql extends InsertQuery {
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
+ // If we're selecting from a SelectQuery, finish building the query and
+ // pass it back, as any remaining options are irrelevant.
if (!empty($this->fromQuery)) {
return "INSERT INTO {" . $this->table . '} (' . implode(', ', $insert_fields) . ') ' . $this->fromQuery;
}