我可以将数据库中的其他表与单一模型 cakephp 一起使用吗?
Can I use other tables in database with single model cakephp?
在 cakephp
中有什么方法可以使用(插入删除更新)tables 数据而无需创建控制器文件和视图文件夹。
我有 table 有控制器的用户 usercontroller.php
。
我可以使用一个模型来使用(插入删除更新)其他 table 的数据,而不是为每个 table 创建单独的控制器文件和视图文件夹吗?
啊抱歉,误会了。
在您的控制器中试试这个:
$this->loadModel('YourModel');
$this->YourModel->create();
$data = array('id' => 123, 'name' => 'Joe');
$this->YourModel->save($data);
在 cakephp
中有什么方法可以使用(插入删除更新)tables 数据而无需创建控制器文件和视图文件夹。
我有 table 有控制器的用户 usercontroller.php
。
我可以使用一个模型来使用(插入删除更新)其他 table 的数据,而不是为每个 table 创建单独的控制器文件和视图文件夹吗?
啊抱歉,误会了。 在您的控制器中试试这个:
$this->loadModel('YourModel');
$this->YourModel->create();
$data = array('id' => 123, 'name' => 'Joe');
$this->YourModel->save($data);