我不知道我的查询出错了,但是dateread的值被忽略了,而且我得到了
错误消息:未定义属性:stdClass :: $ dateread。
SELECT `id`.`id`, `id`.`name`, `id`.`deleted`, `id`.`filepath`, `id`.`createddate`, (SELECT createddate as dateread FROM documents_users iu WHERE id.id = iu.docs_id AND iu.users_id = 2346)
FROM (`documents` AS id)
JOIN `documents_years` AS iy ON `id`.`id` = `iy`.`docs_id`
有人可以帮忙吗?“
答案 0 :(得分:1)
只需更新您的查询,然后在完成sub_query之后获取$dateread
的值,您需要定义dateread
,而不是在sub_query中,否则它将是
(SELECT createddate FROM documents_users iu WHERE id.id = iu.docs_id AND iu.users_id = 2346)
SELECT `id`.`id`, `id`.`name`, `id`.`deleted`, `id`.`filepath`, `id`.`createddate`,
(SELECT createddate FROM documents_users iu WHERE id.id = iu.docs_id AND iu.users_id = 2346) as dateread
FROM (`documents` AS id)
JOIN `documents_years` AS iy ON `id`.`id` = `iy`.`docs_id`