diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-05-03 08:56:19 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-05-03 08:56:19 +0000 |
commit | c5926f4961506ad886e6110bc506bf72e4588bc8 (patch) | |
tree | 6efe325fc02f12a6b8e2e12612fe721ac9bbeac5 /includes/database/query.inc | |
parent | d4193f5178141a3474a08a8f2e77107a5fd5e0a0 (diff) | |
download | brdo-c5926f4961506ad886e6110bc506bf72e4588bc8.tar.gz brdo-c5926f4961506ad886e6110bc506bf72e4588bc8.tar.bz2 |
- Patch #396578 by Damien Tournoud: added db_truncate_table() to the database layer.
Diffstat (limited to 'includes/database/query.inc')
-rw-r--r-- | includes/database/query.inc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/includes/database/query.inc b/includes/database/query.inc index 8c7281820..8cdaaf5e1 100644 --- a/includes/database/query.inc +++ b/includes/database/query.inc @@ -829,6 +829,38 @@ class DeleteQuery extends Query implements QueryConditionInterface { } } + +/** + * General class for an abstracted TRUNCATE operation. + */ +class TruncateQuery extends Query { + + /** + * The table from which to delete. + * + * @var string + */ + protected $table; + + public function __construct(DatabaseConnection $connection, $table, array $options = array()) { + $options['return'] = Database::RETURN_AFFECTED; + parent::__construct($connection, $options); + $this->table = $table; + } + + public function compile(DatabaseConnection $connection) { + return $this->condition->compile($connection); + } + + public function execute() { + return $this->connection->query((string)$this, array(), $this->queryOptions); + } + + public function __toString() { + return 'TRUNCATE {' . $this->connection->escapeTable($this->table) . '} '; + } +} + /** * General class for an abstracted UPDATE operation. */ |