Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cake console baking on different datasource (pluguin array)

I ve installed datasource plugin Array. It do NOT use db tables as source of data. Its an array (source). When i try to bake using cake bake (or something) it doesnt recognize the array source used, only the tables of my database.

I would like to bake all the crud actions as done for datasource database tables as my array datasource. how can i acomplish that ?

ty advance

like image 763
jose mey Avatar asked Dec 02 '25 09:12

jose mey


1 Answers

After you setup your DataSources. If you running the bake command from your root directory where you can see bin folder.

This will give you list of tables

sudo bin/cake bake.bake model --connection OTHER_DATABASE_NAME

Let's say we want to bake for Users table

Bake a model

sudo bin/cake bake.bake model TABLE_NAME --connection OTHER_DATABASE_NAME

In cakephp 3.x

If you want to do it manually you can create your Entity class and Table class as normal. and then in UsersTable.php add this function:

public static function defaultConnectionName()
    {
        return 'OTHER_DATABASE_NAME';
    }
like image 155
Fury Avatar answered Dec 04 '25 02:12

Fury



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!