- Posts: 32
COMMUNITY FORUM
K2 Tools custom php order issue
- Mike Economou
-
Topic Author
- Offline
- Junior Member
Less
More
8 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 :This is the output
If I copy the output and run it in mysql it returns the data fine.
What am I doing wrong ?
Thank you
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;
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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 1 month ago #161241
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
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.
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
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 32
8 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.
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
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 32
8 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 ?
Any update on this please ?
Is something wrong with my query or something ?
Please Log in or Create an account to join the conversation.