summaryrefslogtreecommitdiff
path: root/includes/database/sqlite
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-05-15 07:04:21 +0000
committerDries Buytaert <dries@buytaert.net>2010-05-15 07:04:21 +0000
commit416f87f170cd6d2fe23db676939283cf174ff68c (patch)
tree8b908b76ac86cabc785ca890c08a2acff241a31a /includes/database/sqlite
parent520d8e6e9202f53bad53d4bdaf56ac1d78aba2f6 (diff)
downloadbrdo-416f87f170cd6d2fe23db676939283cf174ff68c.tar.gz
brdo-416f87f170cd6d2fe23db676939283cf174ff68c.tar.bz2
- Patch #785782 by cafuego: support comments in built queries.
Diffstat (limited to 'includes/database/sqlite')
-rw-r--r--includes/database/sqlite/query.inc12
1 files changed, 9 insertions, 3 deletions
diff --git a/includes/database/sqlite/query.inc b/includes/database/sqlite/query.inc
index de8f7f212..08c929bf3 100644
--- a/includes/database/sqlite/query.inc
+++ b/includes/database/sqlite/query.inc
@@ -33,16 +33,19 @@ class InsertQuery_sqlite extends InsertQuery {
}
public function __toString() {
+ // Create a comments string to prepend to the query.
+ $comments = (!empty($this->comments)) ? '/* ' . implode('; ', $this->comments) . ' */ ' : '';
+
// Produce as many generic placeholders as necessary.
$placeholders = array_fill(0, count($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(', ', $this->insertFields) . ') ' . $this->fromQuery;
+ return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') ' . $this->fromQuery;
}
- return 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') VALUES (' . implode(', ', $placeholders) . ')';
+ return $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $this->insertFields) . ') VALUES (' . implode(', ', $placeholders) . ')';
}
}
@@ -143,7 +146,10 @@ class DeleteQuery_sqlite extends DeleteQuery {
*/
class TruncateQuery_sqlite extends TruncateQuery {
public function __toString() {
- return 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '} ';
+ // Create a comments string to prepend to the query.
+ $comments = (!empty($this->comments)) ? '/* ' . implode('; ', $this->comments) . ' */ ' : '';
+
+ return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '} ';
}
}