问题
I am using cake php 3.4. I have guest and country table in database. I want to access these table object as Guests and Contries.
I want to use like this :
$this->Guests->find();
instead of
$this->Guest->find()
回答1:
You have to create a model GuestsTable.php in src/Model/Table/
namespace App\Model\Table;
use Cake\ORM\Table;
class GuestsTable extends Table
{
public function initialize(array $config)
{
$this->setTable('guest'); // your table name
// Prior to 3.4.0
// $this->table('guest');
}
}
Same goes for country
来源:https://stackoverflow.com/questions/43798764/how-to-use-table-name-different-then-in-database-in-cake-php-3