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.
سؤال
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)