2013-04-29 3 views
0
내가 심포니 1.4 교리를 사용하고

, 나는 현재 내 2 개 테이블에 대한 schema.yml 파일의 구조를 만들었지 만 쿼리를 할 때 나는이 예외를doctrine을 사용하여이 모델을 수정하여이 오류를 수정할 수 있습니까?

SQLSTATE [42S22] 얻을 : 찾을 수없는 열 : 1054 'on clause'에서 알 수없는 'o.id'열. 실패한 쿼리 : "SELECT o.id_aditional_details AS o__id_aditional_details, o.name AS o_ 이름, o.type AS o _type, o.group AS o__group FROM ohrm_aditional_details o 내부 조인 orm_details_info o2 ON o.id = o2.ohrm_aditional_details_id WHERE (o2 .user = 4) "

나는 테이블, details_infoaditional_details,이 추가적으로 세부 사항 필드 details_info에서 하나 개의 항목의 ID 중 하나에 필요 한 , 나는 필자가 다른 테이블로 일을하기 때문에이 오류를 잘 모릅니다, 하지만 이번엔 무슨 일이 벌어지고 있는지 전혀 모르겠다. ...

내 schema.yml은 (는)

케이스 $ 아이디 = 4

어떤 생각에서

try 
{ 
    $q = Doctrine_Query::create() 
     ->select('*') 
     ->from('OhrmAditionalDetails D') 
     ->innerJoin('D.OhrmDetailsInfo I') 
     ->where("I.user = $id"); 

    $result = $q->execute(); 
    return $result; 
} 
catch(Exception $e) 
{ 
    print_r ($e->getMessage()); 
    return null; 
} 

매우 간단

OhrmAditionalDetails: 
    connection: doctrine 
    tableName: ohrm_aditional_details 
    columns: 
    id_aditional_details: 
     type: integer(11) 
     fixed: false 
     unsigned: false 
     primary: true 
     autoincrement: true 
    name: 
     type: string(100) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    type: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    group: 
     type: integer(4) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
OhrmDetailsInfo: 
    connection: doctrine 
    tableName: ohrm_details_info 
    columns: 
    id_details_info: 
     type: integer(11) 
     fixed: false 
     unsigned: false 
     primary: true 
     autoincrement: true 
    aditional_info: 
     type: integer(11) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    result: 
     type: string(200) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: false 
     autoincrement: false 
    user: 
     type: integer(11) 
     fixed: false 
     unsigned: false 
     primary: false 
     notnull: true 
     autoincrement: false 
    relations: 
    OhrmAditionalDetails: 
    local: aditional_info 
    foreign: id_aditional_details 
    type: one 
    HsHrEmployee: 
    local: user 
    foreign: emp_number 
    type: one 
내 쿼리? 필자는

php symfony cc 
php symfony doctrine:build-model 
php symfony orangehrm:publish-assets 
php symfony cc 

하지만 아무것도 ... 시도는, 예를에 참여하는 열의 이름을 추측하려고

답변

2

id_aditional_details 대신 id을 찾으십시오.

올바르게 schema.yml에 정의한 것처럼 보입니다. 그러나 yaml을 들여 쓰기하지 않았기 때문에 비어있는 것으로 해석합니다. 시도해보십시오.

relations: 
    OhrmAditionalDetails: 
     local: aditional_info 
     foreign: id_aditional_details 
     type: one 
    HsHrEmployee: 
     local: user 
     foreign: emp_number 
     type: one 
+0

감사합니다 ... 문제는 들여 쓰기 공간 ... 이상한 것들 – jpganz18

+0

예. "yaml을 제대로 들여 쓰지 않았기 때문에이 단어를 비어있는 것으로 해석합니다." 들여 쓰기가 YAML에게 매우 중요합니다. 그것들을 놓치기 쉽습니다 :) – antony