简体   繁体   English

我可以在单一模型cakephp中使用数据库中的其他表吗?

[英]Can I use other tables in database with single model cakephp?

Is there any way in cakephp where I can use (insert delete update) tables data without creating controller files and view folder. cakephp ,有什么方法可以使用(插入删除更新)表数据而无需创建控制器文件和查看文件夹。

I have table user with controller usercontroller.php . 我有控制器usercontroller.php表用户。

Can I use one model to use (insert delete update in) other table's data instead of making individual files of controller and view folder for each table? 我可以使用一种模型来使用(插入删除更新)其他表的数据,而不是为每个表制作单独的控制器文件和视图文件夹吗?

Ah sorry, got you wrong. 抱歉,您理解错了。 Try this in your Controller: 在您的控制器中尝试以下操作:

$this->loadModel('YourModel');
$this->YourModel->create();
$data = array('id' => 123, 'name' => 'Joe');
$this->YourModel->save($data);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM