Cakephp当某些X不属于Y时如何处理
我有一个“单位”表,属于“复杂”。但有些单元实际上是房屋,没有与之相关的综合体。直到现在,我在尝试显示图像时还没有遇到任何问题,因为单位都显示其 UnitsImage 和 ComplexImage。任何房屋都会显示 ComplexImage 未定义的错误(显然)。有没有办法修复关联,或者我是否需要另一个模型?
I have a table of 'units', which belongsTo 'Complex'. But some units are actually houses, which don't have a complex associated with them. I haven't had any problems until now when trying to display images, because units all display their UnitsImage and their ComplexImage. Any houses display an error that ComplexImage not defined (obviously). Is there a way to fix the association or do I need to have another model?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您提供的信息,我认为不需要在模型中进行任何更改。我认为问题在于您认为存在图像。您是否尝试过在视图中使用 if 语句?
也许您可以分享您认为的代码?
Based off of the information you have provided I don't believe any changes need to be made within the model. I assume the issue is that in the view you assume an image exists. Have you tried place using an if statement in the view?
perhaps you could share the code from your view?