프로젝트 (이미 시작한)에 symfony 1.4를 사용하고 있습니다. 이제는 약간의 내용물을 변경하려고합니다. 두 테이블 사이에 정보가 없으면 하나의 이미 존재하고 다른 하나는 새로운 것으로 쿼리 할 때 관계 오류가 발생합니다. 첫 번째 테이블을 가리키는 외래 키가 있어야합니다.심포니가 테이블 간의 새로운 관계를 어떻게 보이게 할 수 있습니까?
와 나는 오류이
exception 'Doctrine_Table_Exception' with message 'Unknown relation alias ' in /var/www/testorange/symfony/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Relation/Parser.php:237
Stack trace: #0 /var/www/testorange/symfony/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Relation/Parser.php(235): Doctrine_Relation_Parser->getRelation('', false)
같은 메시지 ...
많은 오류를 더 얻을.
내 테이블에는 심포니의 내 정의에 대한 적절한 관계가 없기 때문에 생각합니다. (이미 내 DB와 관련되어 있습니다).
나는이 OhrmUser 내가 참조를 만들고 싶어 테이블에OhrmUser:
connection: doctrine
tableName: ohrm_user
columns:
id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
user_role_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
emp_number:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
user_name:
type: string(40)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
user_password:
type: string(40)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
deleted:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '0'
notnull: true
autoincrement: false
status:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '1'
notnull: true
autoincrement: false
date_entered:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
date_modified:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
modified_user_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
created_by:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
HsHrEmployee:
local: emp_number
foreign: emp_number
type: one
OhrmUserRole:
local: user_role_id
foreign: id
type: one
HsHrMailnotifications:
local: id
foreign: user_id
type: many
OhrmLeaveAdjustment:
local: id
foreign: created_by_id
type: many
OhrmLeaveComment:
local: id
foreign: created_by_id
type: many
OhrmLeaveEntitlement:
local: id
foreign: created_by_id
type: many
OhrmLeaveRequestComment:
local: id
foreign: created_by_id
type: many
OhrmTimesheetActionLog:
local: id
foreign: performed_by
type: many
에 대한 정의가
OhrmTrainningSubmit:
connection: doctrine
tableName: ohrm_trainning_submit
columns:
id_trainning_submit:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
trainning:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
trainning_detail:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
answer:
type: string(250)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
state:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '0'
notnull: true
autoincrement: false
user:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
OhrmUser:
local: user
foreign: emp_number
type: many
OhrmTrainning:
local: trainning
foreign: id_trainning
type: many
후 [업데이트]] 내 schema.yml 파일 필드에이 줄을 추가하는 참조가 필드 "emp_number"(나는이 방법으로 올바른 것 같아요) 테이블 "OhrmUser"테이블에 "사용자"입니다, 문제는 여전히 같은 오류가 누구나 이것의 생각을 가지고 있습니까? 내가해야하는 다른 것?
나는 내가 단지 OhrmTrainningSubmit의 데이터에 액세스 할 수 있습니다
try{
$q = Doctrine_Query::create()
->select('*')
->from('OhrmTrainningSubmit TS')
->innerJoin('TS.OhrmUser U')
->addWhere("TS.trainning = $training")
->andWhere("TS.user = $employee");
$result = $q->execute();
return $result;
}catch(Exception $e){
print_r ($e->getMessage());
return null;
}
이
php symfony cc
php symfony doctrine:build-model
php symfony orangehrm:publish-assets
php symfony cc
쿼리를 실행하는 것이 추가,하지만 난 때 내가 얻을 사용자의 필드에 접속을 한 후 내부 오류.
나는 $ 세부 쿼리의 반환 값으로 변수이 코드
foreach ($detail as $det){
echo $det['answer']; // This is printed with no problem
//echo $det['user_name']; <-- this one comes from the table OhrmUser, I get server error with this one
}
에서 오류가 발생합니다. 라고 내가 다른 오류가
->select('TS.*, U.*')
내가 할
,
어떤 생각 emp_number
알 수없는 재산?
미리 감사드립니다.
가 쿼리를 생성하는 코드를 게시 할 수 있습니다 : 오브젝트의 사용에서 데이터를 검색하려면
편집
:에
번역합니다 관계를 추가 한 테이블의 전체 스키마? –
감사합니다. 일부 게시물을 내 게시물에 추가했습니다. 확인해주세요. – jpganz18
'OhrmUser'필드에 액세스하려는 코드를 게시하십시오. 또한'select ('TS. *, U. *)'를 사용하여 사용자 필드의 지연로드를 방지 할 수 있습니다. –