diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-05-15 07:04:21 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-05-15 07:04:21 +0000 |
commit | 416f87f170cd6d2fe23db676939283cf174ff68c (patch) | |
tree | 8b908b76ac86cabc785ca890c08a2acff241a31a /includes/database/mysql | |
parent | 520d8e6e9202f53bad53d4bdaf56ac1d78aba2f6 (diff) | |
download | brdo-416f87f170cd6d2fe23db676939283cf174ff68c.tar.gz brdo-416f87f170cd6d2fe23db676939283cf174ff68c.tar.bz2 |
- Patch #785782 by cafuego: support comments in built queries.
Diffstat (limited to 'includes/database/mysql')
-rw-r--r-- | includes/database/mysql/query.inc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/includes/database/mysql/query.inc b/includes/database/mysql/query.inc index 843e22dfd..63c0fe8e7 100644 --- a/includes/database/mysql/query.inc +++ b/includes/database/mysql/query.inc @@ -43,6 +43,8 @@ class InsertQuery_mysql 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); @@ -50,10 +52,10 @@ class InsertQuery_mysql 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(); @@ -143,6 +145,8 @@ class MergeQuery_mysql extends MergeQuery { public function __toString() { + // Create a comments string to prepend to the query. + $comments = (!empty($this->comments)) ? '/* ' . implode('; ', $this->comments) . ' */ ' : ''; // Set defaults. if ($this->updateFields) { @@ -164,7 +168,7 @@ class MergeQuery_mysql extends MergeQuery { $insert_fields = $this->insertFields + $this->keyFields; - $query = "INSERT INTO {" . $this->table . '} (' . implode(', ', array_keys($insert_fields)) . ') VALUES '; + $query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', array_keys($insert_fields)) . ') VALUES '; $max_placeholder = 0; $values = array(); |