Feature #83020
closedQueryBuilder needs CREATE TABLE, INSERT and DROP TABLE
0%
Description
Sometimes it's necessary to dynamically create or drop tables inside an extension or module. For example if you would like to create a backup-table of "pages", before doing some stuff with it.
As I write this, QueryBuilder isn't able to do this. It would be really great, if you can add those methods!
I would like to do things like
public function backupDatabaseTablePages(){
$query = "DROP TABLE `pages_backup`;";
$this->db->sql_query($query);
$query = "CREATE TABLE pages_backup LIKE pages;";
$this->db->sql_query($query);
$query = "INSERT INTO pages_backup SELECT * FROM pages;";
$this->db->sql_query($query);
}
Thanks a lot
Johannes
Updated by Benni Mack about 5 years ago
- Status changed from New to Needs Feedback
The purpose of the QueryBuilder is to work with the data, not the schema of the database.
For details on this, I consider you have a look at the Connection methods and the AbstractSchemaManager from Doctrine DBAL, which does exactly what you want to do (e.g." schemaManager->dropTable('mytable')").
Let me know if you need anything else, but from as far as I can see, we don't need a wrapper for this, and you can use the SchemaManager (from the connection) directly.
Updated by Johannes C. Schulz about 5 years ago
Benni Mack wrote:
The purpose of the QueryBuilder is to work with the data, not the schema of the database.
hey Benni.
Thanks for your answer. I do not maintain the software anymore which needed this features.
Best regards
Johannes
Updated by Benni Mack over 4 years ago
- Status changed from Needs Feedback to Rejected
OK. WIll close this issue now. CREATE, INSERT etc. is part of the Schema* functionality, not the "QueryBuilder"