English 中文(简体)
A. 儿童模式的成绩数据
原标题:Querying data from a child model

I have 3 models that I have setup thus far in a simple application I am working on:

到目前为止,我有这些模式:

  • UserAccountEntity - Top level Table (Has a One-Many Relationship to UserAccountEntityStrings)
  • UserAccountEntityStrings - Child Table (Has a Many-One relation ship to UserAccountEntity and EavAttributes
  • EavAttributes - Lookup Table

When I query data from my top level table, I get the schema,association information for the child table. But I do not get any of the persisted data from the child table.

我预计结果是什么,高级模型的数据以及相关儿童模式的数据。 我们非常赞赏这方面的任何帮助。

我正在使用Zend 1.11.10和Doctrine 2 ,这或许是有益的。

这是我所问的:

   $users = $em->createQuery( select u from FioboxEntityUserModuleUserAccountEntity u )->execute();
   Zend_Debug::dump($users[0]);

这是我的最高级模式:

/**
 *
 * @param DoctrineCommonCollectionsCollection $property
 * @OneToMany(targetEntity="UserAccountEntityStrings",mappedBy="UserAccountEntity", cascade={"persist","remove"})
 */
private $strings;

These are the associations in my child model:

/**
 *
 * @var UserAccountEntity
 * @ManyToOne(targetEntity="UserAccountEntity")
 * @JoinColumns({
 *  @JoinColumn(name="entity_id", referencedColumnName="entity_id")
 * })
 */
private $user;

/**
 * @var EavAttribute
 * @ManyToOne(targetEntity="FioboxEntityEavModuleEavAttributes")
 * @JoinColumn(name="attribute_id", referencedColumnName="attribute_id")
 */
private $attributes;
最佳回答

你们是否实际尝试了什么?

页: 1 您的var可能显示,贵国的 objects物被持续收集。 但是,如果你能够进入,就会自动装载:

<?php
$users = $em->createQuery( select u from FioboxEntityUserModuleUserAccountEntity u )->fetchAll();

foreach($users as $u){
    foreach($u->strings as $s){
        var_dump($s);
    }
}

If you know that you re going to need all that child data, you might as well force a fetch-join in your DQL:

<?php
$users = $em->createQuery( select u, s from FioboxEntityUserModuleUserAccountEntity u JOIN u.strings s )->fetchAll();
问题回答

暂无回答




相关问题
Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

Tagging with Zend Framework

I m trying to create the same solutions as below, but using a simple MySQL query (instead of the static version used below where the words/tags are implemented in the code). The name of the MySQL ...

dynamicaly adding textboxes to zend_form

I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows ...

热门标签