The queries

2006, július 24 - 14:39

Basically, we'll need two different types of queries:
-select the stiky news
-pull the latest news from categories


Note: don't forget that if a node is sticky and latest, we should take the necessary steps to avoid showing it twice


So we know all, let's see the queries:


Sticky news:(from any category)

$result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type = 'story' AND n.status = 1 AND n.sticky = 1 ORDER BY n.created DESC"), 1);

Means: select the latest node, which is 'story' type and is 'promoted' and 'sticky'.


News for the boxes:

$result1 = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type = 'story' AND term_node.tid = X AND n.status = 1 AND n.sticky = 0 ORDER BY n.created DESC"), 2);
Means: select the latest node, which is 'story' type and is 'promoted' but not 'sticky', from term X and give me two of them.


Well, let's unify our HTML structure with the queries.

nyomtatóbarát változat | Hungarian Hungarian | 1434 olvasás |

Hozzászólás

A mező tartalma nem nyilvános.