2011-05-22 46 views
1

我有以下schema.yaml:排除在DQL 「未知記錄屬性/相關組件」 加入

Artikel: 
connection: doctrine 
tableName: artikel 
columns: 
id: 
    type: integer(4) 
    fixed: false 
    unsigned: true 
    primary: true 
    autoincrement: true 
bezeichnung: 
    type: string(255) 
    fixed: false 
    unsigned: false 
    primary: false 
    notnull: true 
    autoincrement: false 
Portfolio: 
connection: doctrine 
tableName: portfolio 
columns: 
artikel_id: 
    type: integer(4) 
    fixed: false 
    unsigned: true 
    primary: true 
    autoincrement: false 
markt_id: 
    type: integer(4) 
    fixed: false 
    unsigned: true 
    primary: true 
    autoincrement: false 
relations: 
Artikel: 
    local: id 
    foreign: zustand_id 
    type: many 
Portfolio: 
    local: id 
    foreign: zustand_id 
    type: many 

我以下(短)action.class.php文件:

$this->unt_cat_list = Doctrine_Query::create() 
        ->from('portfolio p') 
        ->innerJoin('p.Artikel a') 
        ->Where('p.markt_id = ? ', array(3)) 
        ->andWhere('a.id = ?', array(8)) 
        ->execute(); 

我follwoing gottoSucccess.php文件:

<?php foreach ($unt_cat_list as $cat_list1): ?> 
<a href="<?php echo url_for('shop/category') . '/' . 'id/' . $cat_list1->getMarktId() ?>"><?php echo $cat_list1->getBezeichnung() ?></a> 
<?php endforeach; ?> 

現在我的問題:我想要顯示的列「Bezeichnung」(這我ans:description,所以它是正常的文字)。錯誤是來了一句:

未知記錄屬性/相關組件「bezeichnung」的「投資組合」

它正在與該陣列(3)和(8),因爲條目在db中存在,所以symfony正在加入,對嗎?

如何列出「Bezeichnung」列?有人能幫助我嗎?

回答

2

Bezeichnung是Artikel類的一個列,所以你應該這樣做,並且$cat_list1必須是一個Portfolio(因爲......我認爲它出現在你的from子句中)。所以你應該做的是$cat_list1->getArtikel()->getBezeichnung()(das ist germglish ^^)。

+0

親愛的GregOire,非常感謝!它正在工作,我現在不瞭解課程。坦克一個批次! – craphunter 2011-05-22 17:43:10

+0

Bitteschön:-) – greg0ire 2011-05-22 17:44:19

相關問題