2010-03-18 38 views
1

我有兩個表的UserDetails和博客討論的模式是加入教義的symfony查詢

UserDetails: 
    connection: doctrine 
    tableName: user_details 
    columns: 
    id: 
     type: integer(8) 
     fixed: false 
    name: 
     type: string(255) 
     fixed: false 

BlogQuestion: 
    connection: doctrine 
    tableName: blog_question 
    columns: 
    question_id: 
     type: integer(8) 
     fixed: false 
     unsigned: false 
     primary: true 
     autoincrement: true 
    blog_id: 
     type: integer(8) 
     fixed: false 
    user_id: 
     type: integer(8) 
     fixed: false 
    question_title: 
     type: string(255) 

我使用一個從這個兩個表我的連接查詢檢索所有的問題和用戶信息加入查詢

$q = Doctrine_Query::create() 
    ->select('*') 
    ->from('BlogQuestion u') 
    ->leftJoin('u.UserDetails p'); 
    $q->execute(); 

但其顯示的錯誤未知的關係別名的UserDetails

請人幫助我

在此先感謝

回答

2

爲什麼你沒有在你的教條中建立關係?

UserDetails: 
    connection: doctrine 
    tableName: user_details 
    columns: 
    id: 
     type: integer(8) 
     fixed: false 
     unsigned: false 
     primary: true 
     autoincrement: true 

BlogQuestion: 
    connection: doctrine 
    tableName: blog_question 
    columns: 
    question_id: 
     type: integer(8) 
     fixed: false 
     unsigned: false 
     primary: true 
     autoincrement: true 
    blog_id: 
     type: integer(8) 
     fixed: false 
    user_id: 
     type: integer(8) 
     fixed: false 
    question_title: 
     type: string(255) 
    relations: 
    UserDetails: 
     local: user_id 

在你的yml中沒有任何東西可以告訴主義當你離開join時應該鏈接什麼。我剛剛建立這個自己,它確實工作

+0

謝謝,但是當我運行symfony準則:構建 - 所有 - 無確認 它shoeing一個錯誤在路徑BlogQuestion-> columns->名爲「本地」 UserDetails – Warrior 2010-03-18 07:56:29

+0

對不起THOmas我有點累我糾正了它 – plod 2010-03-18 07:58:46

+0

然後它也顯示相同的錯誤 在路徑BlogQuestion-> columns-> UserDetails – Warrior 2010-03-18 08:01:17