MyBB Community Forums
[F] Column averagerating does not exist - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.4.1 (https://community.mybb.com/forum-93.html)
+------ Thread: [F] Column averagerating does not exist (/thread-36256.html)



[F] Column averagerating does not exist - Michael S. - 2008-08-20

Quote:<error>
<dateline>1219123972</dateline>
<script></script>
<line>0</line>
<type>20</type>
<friendly_type>MyBB SQL Error</friendly_type>
<message>SQL Error: 1054 - Unknown column 'averagerating' in 'order clause'
Query:
SELECT t.*, t.username AS threadusername, u.username
FROM mybb_threads t
LEFT JOIN mybb_users u ON (u.uid = t.uid)
WHERE t.fid='11' AND t.visible='1'
ORDER BY t.sticky DESC, averagerating desc , t.totalratings DESC
LIMIT 0, 20
</message>
</error>
The column averagerating does not exist. The query can be found in the file forumdisplay.php (line 643).


RE: Column averagerating does not exist - Ryan Gordon - 2008-08-20

Which SQL Engine?


RE: Column averagerating does not exist - Michael S. - 2008-08-20

A user reported this issue in the german community. I'll ask him about that.

But I think it doesn't matter because if you search for "averagerating" in the files mysql_db_tables.php, pgsql_db_tables.php and sqlite_db_tables.php you get no result. But in the file forumdisplay.php you can find this:
        case "rating":
		$t = "";
		$sortfield = "averagerating";
		$sortfield2 = ", t.totalratings DESC";
		break;
Edit: He's using MySQLi.


RE: Column averagerating does not exist - Ryan Gordon - 2008-08-20

No, averagerating is simply a reference column created during the query.

$ratingadd = "(t.totalratings/t.numratings) AS averagerating, ";

Ask him to try this


RE: Column averagerating does not exist - Michael S. - 2008-08-21

Doesn't work:
Quote:<error>
<dateline>1219297785</dateline>
<script></script>
<line>0</line>
<type>20</type>
<friendly_type>MyBB SQL Error</friendly_type>
<message>SQL Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc
LIMIT 0, 20' at line 5
Query:
SELECT t.*, t.username AS threadusername, u.username
FROM mybb_threads t
LEFT JOIN mybb_users u ON (u.uid = t.uid)
WHERE t.fid='24' AND (t.visible='1' OR t.visible='0')
ORDER BY t.sticky DESC, t. desc
LIMIT 0, 20
</message>
</error>



RE: Column averagerating does not exist - Ryan Gordon - 2008-08-21

Does this work?


RE: Column averagerating does not exist - Michael S. - 2008-08-25

The user still gets this errors.
Quote:<error>
<dateline>1219622893</dateline>
<script></script>
<line>0</line>
<type>20</type>
<friendly_type>MyBB SQL Error</friendly_type>
<message>SQL Error: 1054 - Unknown column 'averagerating' in 'order clause'
Query:
SELECT t.*, t.username AS threadusername, u.username
FROM mybb_threads t
LEFT JOIN mybb_users u ON (u.uid = t.uid)
WHERE t.fid='18' AND t.visible='1'
ORDER BY t.sticky DESC, averagerating asc , t.totalratings DESC
LIMIT 20, 20
</message>
</error>



RE: Column averagerating does not exist - Ryan Gordon - 2008-08-25

Alright, I need more information. Tell me how to do this. Give an example or something.


RE: Column averagerating does not exist - WDZ - 2008-08-25

One way to reproduce it is to disable thread ratings in the forum, then try to sort by rating. I could have sworn I reported that as a bug in one of the 1.2 betas... hmm :/


[F] Column averagerating does not exist - Ryan Gordon - 2008-08-26

Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.