duanlaofu4108 2013-06-29 11:27
浏览 16

如何在蓬勃发展中定义外键路线?

I am using PHP with Flourish. I read their documentation here and here. Let's suppose I have a table persons and another table items. Let's suppose further that I have an item_id1 and an item_id2 in the persons table. Both of them are foreign keys to the items table. I would like to get a record from the items table based on the relation between persons and items based on the item_id2 foreign key.

If I am not mistaken this could be achieved with

$person->createItem()

if $person is the fActiveRecord generated from a record of the persons table in most of the cases. But in this particular case, when multiple foreign keys point to the very same table. This is understandable, because Flourish is not able to determine which relation should be used if we do not give it at least a route.

So, if we want to get the record from the items table which corresponds to the item_id2 foreign key, then we should give the route as parameter. I didn't see a description or an example in their documentation which addresses this particular problem, so my question is:

How should we tell createItem that I want to use the item_id2 key?

$person->createItem("item_id2")

does not work.

  • 写回答

1条回答 默认 最新

  • doulun1915 2014-02-07 19:52
    关注

    You are right, your example should work. I just checked and I can tell that it works for me. The only difference I can spot between your example and the documentation is, that you are using double quotes. Try single quotes.

    $person->createItem('item_id2')
    

    I think that might be all it takes to make it work.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测