2012-01-20 4 views
1

Department、Type、Userの3つのテーブルから取得したリストがあります。このように表示symfony 1.4で設定されているforeignAliasの行だけを表示する方法

$this->departments = Doctrine_Core::getTable('Department') 
     ->createQuery('a') 
     ->orderBy('a.name') 
     ->execute(); 

indexSuccess.phpと

<?php foreach ($departments as $dept): ?> 
     <tr> 
     <?php check_for_id() ?> 
     <td colspan="4" class="displayDept" valign="top"><?php echo $dept->getName() ?></td> 
    </tr> 
    <tr> 
    <?php foreach ($dept->getUsers() as $user): ?> 
    <tr> 
     <td class="displayInfo" valign="top"><?php echo $user->getType() ?></td> 
     <td class="displayInfo" valign="top"><a href="<?php echo $user->getUrl() ?>" target="_blank"><?php echo $user->getUrl() ?></a></td> 
     <td class="displayInfo" valign="top"><?php echo simple_format_text($user->getDescription()) ?></td> 
    </tr> 
    <?php endforeach; ?> 
    <?php endforeach; ?> 

のactions.class.phpから

Film 
student  Jimmy Stewart 
faculty  Cary Grant 

しかし、これは引っ張りのforeachをもたらしますすべてのID部門表の下に空の行がいくつか残されます。このように:

Photography 
student  Keanu Reeves 
faculty  Lawrence Fishburn 

Drawing 

Film 
    student  Jimmy Stewart 
    faculty  Cary Grant 

Painting 

Sculpture 

ユーザーIDのない部門を削除できますか?

UPDATE

私は、私はアクションであることどのように呼んでください、参加を使用するつもりですか?私はこれまでだところですが、私の反復のどれも機能していない:

$this->departments = Doctrine_Core::getTable('Department') 
     ->createQuery('a') 
     ->leftJoin('a.Users p') 
     ->orderBy('a.name ASC') 
     ->execute(); 

私はそれはしかし何をするかわかりません。伝統的なPHPのようにWHEREを理解できますが、symfonyの構文に従うことはできません。私も終わりですか?

答えて

関連する問題