Solve the problem of Unknowncolumn 't. fid' in 'onclause' in the secondary development of Discuz.

Source: Internet
Author: User
Tags sql error
Errormessages: [Type] query statement error [1054] Unknowncolumnt. fidinonclause [Query] SELECTattach. *, t. tid, t. author, t. authorid, t. subject, f. namegroupnameFROM 'forum _ attachment 'attac

Error messages:


[Type] query statement error
[1054] Unknown column 't. fid' in 'On clause'
[Query] SELECT attach. *, t. tid, t. author, t. authorid, t. subject, f. name groupname FROM 'forum _ attachment 'attach left join forum_forum f ON t. fid = f. fid left join forum_forumfield ff ON f. fid = ff. fid inner join 'forum _ thread' t ON 'T '. 'tid' = 'Attach '. 'tid' AND 'displayorder'> = '0' WHERE 'Attach '. 'Dateline '> = '20140901' AND 'Attach '. 'readperm' = '0' AND 'Attach '. 'price' = '0' AND t. isgroup = '1' AND 'Attach '. 'isimage' IN ('1', '-1') order by 'Attach '. 'Dateline 'desc limit 0, 4;


Program messages:

[Line: 0034] group. php (require)
[Line: 0140] source/module/group/group_index.php (include)
[Line: 0429] data/template/nvidiy_group_index.tpl.php (output)
[Line: 1022] source/function/function_core.php (block_updatecache)
[Line: 0204] source/function/function_block.php (block_groupattachment-> getdata)
[Line: 0298] source/class/block/group/block_groupattachment.php (DB-> query)
[Line: 0837] source/class/class_core.php (DB-> _ execute)



Localhost has recorded the error details, and we apologize for any inconvenience caused.

The error is because t. fid is called in advance when the association in forum_thread (table t) is not introduced, resulting in an SQL error,
I checked it online and couldn't solve the problem. I went to the official forum to check the problem. someone raised the problem, but there was no solution. I had to read the source code of Kangsheng by myself.

The final locking problem lies in source/class/block/group/block_groupattachment.php.

Original


FROM '". DB: table ('forum _ attachment')." 'Attach $ "wp_keywordlink_affiliate"> sqljoin
Inner join '". DB: table ('forum _ thread')."' t
ON 'T'. 'tid' = 'Attach '. 'tid' AND 'displayorder'> = '0'

Correct after modification


FROM '". DB: table ('forum _ attachment')." 'Attach
Inner join '". DB: table ('forum _ thread')."' t
ON 'T'. 'tid' = 'Attach '. 'tid' AND 'displayorder'> = '0'
$ "Wp_keywordlink_affiliate"> sqljoin

I am afraid this is a BUG. I personally think the Discuz X code is messy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.