By ziobudda on
Hi all. I have this query:
select * from term_node tn LEFT JOIN node n on tn.nid = n.nid where tn.tid = 1157 ORDER BY n.created;
That is executed in this piece of code (in my modules):
$query = "select * from {term_node} tn
LEFT JOIN {node} n on tn.nid = n.nid
where tn.tid = ".$tid[0]->tid."
ORDER BY n.created";
echo $query;
$result = pager_query($query, 10);
while($data = db_fetch_object($result)) {
$node = node_load($data->nid);
$out .= theme("node",$node);
}
Now I want to add pager funciont so I have read to add this line to my module:
$out .= theme('pager',NULL,10);
Is this correct ? I ask this because in my DB there are only 5 term node that have tid = 1157, but for drupal there are 587 results (I have see this inserted a line into theme_pager() function).
Why this ? Where is the error ?
M.
Comments
The first argument of pager
The first argument of pager should be an array. so maybe try:
The function itself will take care if you have <10 items so this should be fine as is.
hth,
Not works
tnx for the reply, but my problem is not resolved. I don't know how e why, but for only 10 node (SELECT COUNT(*)) , drupal think that there are 58 nodes.
M.
Freelancer Senior Drupal Developer -- http://www.ziobuddalabs.it
I am having the exact same
I am having the exact same issue on Drupal 5.3.
In the database, only three records are returned. However, the theme('pager') call creates next and previous links, and 9 page links.
Any ideas where to start looking?
You are NOT going to believe
You are NOT going to believe this...
The answer (for me, at least) was found here: http://www.krisbuytaert.be/blog/?q=taxonomy/term/484
My query was all in lower case, and the code in pager.inc is doing a preg_replace on the query without being case insensitive.
I changed my query to:
And it works now.
I'm not belive it
I run into the same problem. After i checked the caps, the query still didn't worked. Than I change it from:
$query = "
SELECT n1.nid, f.filepath, d.field_sex_value
FROM
{node} AS n1,
{node} AS n2,
{files} AS f,
{content_type_date_personale} AS d
WHERE
n1.type = 'tip_poza_utilizator'
AND n2.type = 'date_personale'
AND n1.uid = n2.uid
AND f.nid = n1.nid
AND d.nid = n2.nid
";
to
$query = "SELECT n1.nid, f.filepath, d.field_sex_value FROM {node} AS n1, {node} AS n2, {files} AS f, {content_type_date_personale} AS d WHERE n1.type = 'tip_poza_utilizator' AND n2.type = 'date_personale' AND n1.uid = n2.uid AND f.nid = n1.nid AND d.nid = n2.nid";
And it worked.
Hope that helpes.