Keyword

K2 Tools custom php order issue

  • Mike Economou
  • Mike Economou's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 1 month ago #161208 by Mike Economou
K2 Tools custom php order issue was created by Mike Economou
Hi,
I am trying to get the latest items from a category ordered by created date. But what I get is always the same order (by id) no matter what I do in my query.

This is my query code :
$query
  ->select($db->quoteName(array('a.id', 'a.introtext', 'a.alias', 'a.catid', 'a.published', 'a.created')))
  ->select($db->quoteName('b.id', 'idCat'))
  ->select($db->quoteName('b.alias', 'catAlias'))
  ->select($db->quoteName('b.name', 'catName'))
  ->from($db->quoteName('#__k2_items', 'a'))
  ->join('LEFT', $db->quoteName('#__k2_categories', 'b') . ' ON (' . $db->quoteName('a.catid') . ' = ' . $db->quoteName('b.id') . ')')
  ->where($db->quoteName('a.catid') . ' IN ('. $id . ')  AND ' . $db->quoteName('a.published') . ' = '. 1)
  ->order($db->quoteName('a.created'), DESC)
  ->setLimit(10);
echo $query;
This is the output
SELECT `a`.`id`,`a`.`introtext`,`a`.`alias`,`a`.`catid`,`a`.`published`,`a`.`created`,`b`.`id` AS `idCat`,`b`.`alias` AS `catAlias`,`b`.`name` AS `catName` FROM `jk2_k2_items` AS `a` LEFT JOIN `jk2_k2_categories` AS `b` ON (`a`.`catid` = `b`.`id`) WHERE `a`.`catid` IN (14) AND `a`.`published` = 1 ORDER BY `a`.`created` DESC LIMIT 10

If I copy the output and run it in mysql it returns the data fine.

What am I doing wrong ?

Thank you

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 month ago #161241 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Tools custom php order issue
Stupid question.
Is it possible that you are viewing cached data?
Since this is a module the same data will be displayed regardless of the query for a given amount of time.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Mike Economou
  • Mike Economou's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 1 month ago #161249 by Mike Economou
Replied by Mike Economou on topic K2 Tools custom php order issue
Hi Krikor,

No caching is globally disabled and in the module the same.
I cleared it though just to be sure.

That is why I was wondering if is something wrong with my query.

Please Log in or Create an account to join the conversation.

  • Mike Economou
  • Mike Economou's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 3 weeks ago #161308 by Mike Economou
Replied by Mike Economou on topic K2 Tools custom php order issue
Krikor,

Any update on this please ?
Is something wrong with my query or something ?

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum