Project

General

Profile

Actions

Feature #83020

closed

QueryBuilder needs CREATE TABLE, INSERT and DROP TABLE

Added by Johannes C. Schulz over 6 years ago. Updated about 4 years ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Start date:
2017-11-17
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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

Actions #1

Updated by Benni Mack over 4 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.

Actions #2

Updated by Johannes C. Schulz over 4 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

Actions #3

Updated by Benni Mack about 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"

Actions

Also available in: Atom PDF