Moving on from a cakephp 2 application, I am stuck on trying to use $tablePrefix in my models. Is this still available in Cake 3? Or how can I use something else (please explain).
Table prefixes are gone for now. There is an open PR, however it's not clear at this point when, and if at all this is going to make it:
https://github.com/cakephp/cakephp/pull/4505
As mentioned by Lorenzo in the comments, an alternative might be using events to initialize models with a prefixed table name:
For people still wanting support for prefixes in their tables, there is a way to support it using events. This will probably work for all table operations. Add it to your bootstrap.php file: EventManager::instance()->on('Model.initialize', function ($event, $instance) { $instance->table('prefix_' . $instance->table()); });
For people still wanting support for prefixes in their tables, there is a way to support it using events. This will probably work for all table operations. Add it to your bootstrap.php file:
EventManager::instance()->on('Model.initialize', function ($event, $instance) { $instance->table('prefix_' . $instance->table()); });
https://github.com/cakephp/cakephp/pull/4505#issuecomment-76154855
2.1m questions
2.1m answers
60 comments
57.0k users