English 中文(简体)
理论/声明 表格:意外行为
原标题:Doctrine / Symfony Joining tables: unexpected behavior

我正试图通过根据该条从几个表格中加入几个记录来实现一些增效:。 加入有关记录。 我的模式是,我有一个跟踪器,有一个链接,它反过来又有多个链接。 现在,在我的主计长中,我想通过这些联系:

foreach ($tracker->getLinkset()->getLinks() as $link) etc..

此外,我追踪存放处的守则如下:

public function findWithLinks(Tracker $tracker)
{
      $query = $this->createQueryBuilder( t )
                    ->select( t, ls, l )
                    ->innerJoin( t.linkset ,  ls )
                    ->leftJoin( ls.links ,  l )
                    ->where( t.id = :trackerId )
                    ->setParameters(array(
                           trackerId  => $tracker->getId()
                    ));

      return $query->getQuery()->getResult();
}

我期望的是,在控制人员中,当我通过桌旁听时,由于我有线人,并加入了链接,因此,外来语地名不会再向数据库发出任何电话。 然而,另外还有两个问题,分别处理链接和链接。 下面是相关实体的地图:

www.un.org/Depts/DGACM/index_spanish.htm 链接实体:

/**
  * @var Link
  *
  * @ORMManyToMany(targetEntity="Link", mappedBy="linkset")
  */
  private $links;

The Link entity

/**
  * @var Linkset
  *
  * @ORMManyToMany(targetEntity="Linkset", inversedBy="link")
  * @ORMJoinTable(name="linkcombo",
  *   joinColumns={
  *     @ORMJoinColumn(name="link_id", referencedColumnName="id", onDelete="CASCADE")
  *   },
  *   inverseJoinColumns={
  *     @ORMJoinColumn(name="linkset_id", referencedColumnName="id", onDelete="CASCADE")
  *   }
  * )
  */
  private $linkset;
问题回答

难道你会把你的“前言”的说法改为这样的内容?

foreach( $tracker->getLinkset() as $linkset ) {
    foreach( $linkset->getLinks() as $link ) {
        ....
    }
}

我希望它能帮助!

http://www.ohchr.org。

如果“联系”和“联系”之间的关系仅仅是一种许多惯性的关系,那么我会改变说明,这样看:

<>联系实体:

/**
 * @ORMManyToMany(targetEntity="Link")
 **/
private $links;

The Link entity:

/**
 * @ORMManyToMany(targetEntity="Linkset")
 */

此项工作应假定:

  • Both Link and Linkset entities share the same namespace, otherwise you should change the targetEntity="XXX" to be fully qualified (i.e.: YourBundleEntitiesLinkset and YourOtherBundleEntitiesLink
  • The relation between Tracker and Linkset is OK (did you checked that?)

我确信,比我更能帮助你,我最近开始使用假名。





相关问题
Can t use "Skip" in LINQ query

I have a linq query in which I need to specifically do a left join. However when I attempt to commit a lambda Skip function on the query it errors and says that the skip cannot be performed on a linq ...

sql joins and getting used to them [closed]

I had a big interview that I screwed up when the interviewer asked me to join three tables. I can verbally describe the different types of joins, but I froze up. I m looking for something that gets ...

Using annotations to implement a static join in hibernate

I m relatively new to hibernate and was wondering if someone could help me out. While I have no issues implementing a normal join on multiple columns in hibernate using the @JoinColumns tag, I m ...

LEFT OUTER JOIN (gives extra rows) problem

I have two tables which I want to join together using a left outer join. However, even though my left table contains only unique values, the right table satisfies the CONDITION more than once and as ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

Priming read for PHP Query

I am new to PHP and working on my own CMS for a project. Mostly to just give myself a project to learn the language. The CMS is working but I am just tracking down some bugs in it. So here it goes.....

Select statement performance

I m having a performance issue with a select statement I m executing. Here it is: SELECT Material.* FROM Material INNER JOIN LineInfo ON Material.LineInfoCtr = LineInfo.ctr INNER JOIN ...

热门标签