Reputation: 47
I am installing the cake 3.0 in a database outside the convention, all the tables are with capital letter making the bake return this error:
Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.c_a_d_b_e_m' doesn't exist in [/var/www/project/vendor/cakephp/cakephp/src/Database/Schema/Collection.php, line 130]
Do you have any way to set up Inflector to identify the bake tables with capital letter ?
Upvotes: 1
Views: 734
Reputation: 83
I've found this to be helpful when using non-standard table names:
$> php bin/cake.php bake model PLURAL_MODEL_NAME_HERE --table NON_STANDARD_TABLE_NAME_HERE
Then, you can run the template / controllers
$> php bin/cake.php bake controller PLURAL_MODEL_NAME_HERE
$> php bin/cake.php bake template PLURAL_MODEL_NAME_HERE
Upvotes: 3
Reputation: 34837
Unfortunately the bake utility can't bake everything for you if the existing datasource is not following convention. You will need to create the Table Objects yourself and set the custom table names in there. So for the example you've shown, create a src/Model/Table/Cadbem.php
file and set the custom table name it it's initialize
method:
namespace App\Model\Table;
use Cake\ORM\Table;
class CadbemTable extends Table
{
public function initialize(array $config)
{
$this->table('CADBEM');
}
}
Once you have that, you can create the Controllers/Views with the bake utility based on this table object.
Upvotes: 2