From 416f87f170cd6d2fe23db676939283cf174ff68c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 15 May 2010 07:04:21 +0000 Subject: - Patch #785782 by cafuego: support comments in built queries. --- includes/database/pgsql/query.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'includes/database/pgsql') diff --git a/includes/database/pgsql/query.inc b/includes/database/pgsql/query.inc index 0420f4aad..cb1b94ba2 100644 --- a/includes/database/pgsql/query.inc +++ b/includes/database/pgsql/query.inc @@ -71,6 +71,8 @@ class InsertQuery_pgsql extends InsertQuery { } public function __toString() { + // Create a comments string to prepend to the query. + $comments = (!empty($this->comments)) ? '/* ' . implode('; ', $this->comments) . ' */ ' : ''; // Default fields are always placed first for consistency. $insert_fields = array_merge($this->defaultFields, $this->insertFields); @@ -78,10 +80,10 @@ class InsertQuery_pgsql extends InsertQuery { // 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; + return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') ' . $this->fromQuery; } - $query = "INSERT INTO {" . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES '; + $query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES '; $max_placeholder = 0; $values = array(); -- cgit v1.2.3