문제

I have a page that lists all the employees working in the company. It's been working fine all the time until I added virtual fields to the Users Model.

Now it's giving me the following error:

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'HrEmployee.name'
in 'field list'

SQL Query: SELECT `User`.`id`, `User`.`username`, `User`.`password`,
`User`.`hr_employee_id`, `User`.`group_id`, `User`.`created`, `User`.`modified`,
(CONCAT(`HrEmployee`.`name`, " ", `HrEmployee`.`surname`, " (",
`HrEmployee`.`jobTitle`, ")")) AS `User__fullname` FROM `intraweb_db`.`users`
AS `User` WHERE `User`.`hr_employee_id` = (182)

I am new to cakePHP and as such have been trying to solve the issue. However, I am struggling. Can anyone tell me what I'm doing wrong?

도움이 되었습니까?

해결책 2

Ok so I fixed it by just removing the Users reference under $hasmany. We don't need it to call that page, so it's all fine.

It works now.

다른 팁

Assuming HrEmployee is another table here;

SELECT 
    u.id, u.username, u.password,
    u.hr_employee_id, u.group_id, u.created, u.modified,
    (
        CONCAT(HrEmployee.name, " ", HrEmployee.surname, " (", HrEmployee.jobTitle, ")")
    ) AS u__fullname 
FROM intraweb_db.users AS u 
# need to join HrEmployee via related field with users
JOIN HrEmployee ON (HrEmployee.RELATED_FIELD = u.RELATED_FIELD)
WHERE u.hr_employee_id = (182)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top