简体   繁体   English

如何从相关表中检索所有记录?

[英]How to retrieve all records from related tables?

I have a table called "informations" (http://pastebin.com/h3UiUhpx) and also have this associated tables "educations", "attachments" and "experiences" (http://pastebin.com/RdWzfria) (please see pastebin URLs I put the code there to not ugly the post). 我有一个名为“信息”的表格(http://pastebin.com/h3UiUhpx),并且还有与此相关的表格“教育”,“附件”和“经验”(http://pastebin.com/RdWzfria)(请参阅pastebin URL,我将代码放到那里而不是丑陋的帖子)。 As you may notice all this tables have a relationship with informations so data coming from informations form is saved there. 您可能会注意到,所有这些表都与信息有关系,因此将来自信息表格的数据保存在此处。 I use bake for create the models, views and controllers for this tables. 我使用bake为该表创建模型,视图和控制器。 Now when I add all is fine except for the attachments because it's a FILE input type and I don't know how to handle this part so any help will be very appreciated but the problem here is when I try to edit any records for informations table because none record from the relations tables is showed and don't know the cause. 现在,当我添加所有内容时,除了附件之外的其他内容都很好,因为它是FILE输入类型,并且我不知道如何处理此部分,因此将不胜感激,但是这里的问题是当我尝试编辑信息表的任何记录时因为没有显示关系表中的记录,也不知道原因。 The code for informations model is here: http://pastebin.com/bEY3beBw , for the Controller is here: http://pastebin.com/muAQn3aH and for the view is here: http://pastebin.com/AEhPPCX0 , can any help to fix this? 信息模型的代码在这里: http : //pastebin.com/bEY3beBw ,控制器在这里: http : //pastebin.com/muAQn3aH ,视图在这里: http : //pastebin.com/AEhPPCX0 ,有什么可以解决的吗? Cheers and thanks in advance 预先加油和感谢

Put a pr($this->request->data) at the bottom of your edit function of the controller. pr($this->request->data)放在控制器的编辑功能底部。 It will show you that the model data is coming back just fine. 它将向您显示模型数据恢复正常。 You need to correct your edit.ctp view to handle the information correctly. 您需要更正edit.ctp视图以正确处理信息。

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

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