[Typo3-dev] Bug. Very simple to correct. If I'm correct :-)

Stig N. Jepsen stig at 8620.dk
Thu Apr 1 18:51:19 CEST 2004


Regarding
the getWhere() function of
class.tslib_content.php,v 1.9 2003/12/19 22:49:04

Now, I'm not sure if this is corrected in later versions of this class.

When will this bug be a problem?:
If you want to use both the group by clause and the order by clause in the
same select statement.

According to the MySQL manual about the SELECT syntax:
http://www.mysql.com/doc/en/SELECT.html
Here you can see in which order the different clauses should come.

I have found that in v 1.9 of this class the order is incorrect.

Wrong order:
  // order By
  if (trim($conf['orderBy'])) {
   $query.=' ORDER BY '.trim($conf['orderBy']);
  }
  // group By
  if (trim($conf['groupBy'])) {
   $query.=' GROUP BY '.trim($conf['groupBy']);
  }

Correct order:
  // group By
  if (trim($conf['groupBy'])) {
   $query.=' GROUP BY '.trim($conf['groupBy']);
  }
  // order By
  if (trim($conf['orderBy'])) {
   $query.=' ORDER BY '.trim($conf['orderBy']);
  }

That's all.

/Stig






More information about the TYPO3-dev mailing list