douxian4376 2011-02-19 16:20
浏览 7

没有关系的学说加入[重复]

Possible Duplicate:
Is this possible to join tables in doctrine ORM without using relations?

I have 2 classes Month and Vegetable. They don't have any relation together.

I would like to play the SQL : SELECT * FROM month, vegetable

In MySQL it works perfectly. I try it like that in Doctrine:

    $months = Doctrine_Query::create()
      ->select('m.*, v.*')
      ->from('month m, vegetable v')
      ->execute();

When I try it, I get :

"vegetable" with an alias of "v" in your query does not reference the parent component it is related to.

Does anyone know why ?

Is it possible to make what I want with doctrine ?

  • 写回答

1条回答 默认 最新

  • dongzhong2018 2011-02-19 23:19
    关注

    First Doctrine is using DQl and not SQL.

    DQL is using Objects, so Doctrine try to get a Relation from month to vegetable, but there isn't any relation.

    When you want this to do with Doctrine, you must do two Queries and fetch them as Array and join them.

    评论

报告相同问题?

悬赏问题

  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录