CodeIgniter Forums
protected $DBGroup = 'ywl_data'; - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: protected $DBGroup = 'ywl_data'; (/thread-74555.html)



protected $DBGroup = 'ywl_data'; - aparedesv - 10-08-2019

Hi,

I have some DBgroups declared in App/Config/Database:

// localhost
public $ywl_config = [
'DSN'      => '',
'hostname' => 'localhost',
'username' => 'yachtworklist',
'password' => 'REDACTED',
'database' => 'ywl_config',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug'  => (ENVIRONMENT !== 'production'),
'cacheOn'  => false,
'cacheDir' => '',
'charset'  => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre'  => '',
'encrypt'  => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port'    => 3306,
];

public $ywl_data = [
'DSN'      => '',
'hostname' => 'localhost',
'username' => 'yachtworklist',
'password' => 'REDACTED',
'database' => 'ywl_data',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug'  => (ENVIRONMENT !== 'production'),
'cacheOn'  => false,
'cacheDir' => '',
'charset'  => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre'  => '',
'encrypt'  => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port'    => 3306,
];


and I want that each migration file call their DataBase, but all of migrations files call DataBase defined in $defaultGroup

class BoatDecks extends Migration
{
protected $DBGroup = 'ywl_data'; // doesn't work!!!!

public function up()
{
$this->forge->addField([
'id' => [
'type' => 'SERIAL'
],
'id_boat' => [
'type' => 'INT',
'constraint' => '4'
],
'deck_name' => [
'type' => 'VARCHAR',
'constraint' => '25'
]
]);

$this->forge->addField("created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP()");
$this->forge->addField("updated_at TIMESTAMP NULL");
$this->forge->addField("deleted_at TIMESTAMP NULL");
$this->forge->addKey('id', TRUE);
$this->forge->createTable('ywl_data_boat_decks');
}

//--------------------------------------------------------------------

public function down()
{
$this->forge->dropTable('ywl_data_boat_decks');
}
}


thank's!


RE: protected $DBGroup = 'ywl_data'; - MGatner - 10-08-2019

Were you using the framework from the last develop branch? This was fixed literally 10 hours ago: https://github.com/codeigniter4/CodeIgniter4/pull/2303


RE: protected $DBGroup = 'ywl_data'; - aparedesv - 10-08-2019

Uauhhhhhh!!!

it works perfectly, thanks a lot!