transStart example

/** * Called after `fromTable` and any actions, like `dropColumn`, etc, * to finalize the action. It creates a temp table, creates the new * table with modifications, and copies the data over to the new table. * Resets the connection dataCache to be sure changes are collected. */
    public function run(): bool
    {
        $this->db->query('PRAGMA foreign_keys = OFF');

        $this->db->transStart();

        $this->forge->renameTable($this->tableName, "temp_{$this->tableName}");

        $this->forge->reset();

        $this->createTable();

        $this->copyData();

        $this->forge->dropTable("temp_{$this->tableName}");

        
Home | Imprint | This part of the site doesn't use cookies.