(1.8.9) getTotalRows works on first pod only.
Hi. I upgraded to 1.8.9 and getTotalRows started to act different:
<?php
$pod1 = new Pod ('vste_madeby'); //2 records
$pod2 = new Pod ('discogs_style'); //5 or 6 records
$pod3 = new Pod ('links_cat'); //5 records
$pod4 = new Pod ('links'); //up to 50 records
$pod1->findRecords('name ASC');
$pod2->findRecords('name ASC');
$pod3->findRecords('name ASC');
$rows1 = $pod1->getTotalRows();
$rows2 = $pod2->getTotalRows();
$rows3 = $pod3->getTotalRows();
while ( $pod3->fetchRecord() )
{
$pod3name = $pod3->get_field('name');
$pod4->findRecords('name ASC', "link_category.name = '$pod3name'");
$rows4 = $pod4->getTotalRows();
echo '<br>Link Category: ', $pod3name, ', rows: ', $rows4;
}
echo '<br><br>Pod 1: ', $rows1, ' rows <br> Pod 2: ', $rows2, ' rows <br> Pod 3: ', $rows3, ' rows';
?>
this code outputs following results:
Link Category: Development, rows: 2 Link Category: Forums, rows: 2 Link Category: Friends, rows: 2 Link Category: Inspirers, rows: 2 Link Category: Labels, rows: 2 Pod 1: 2 rows Pod 2: Resource id #140 rows Pod 3: Resource id #140 rows
The while section can allow dynamic category update (hide unused categories and display used as soon as they get first record by simple "if $total_records>0"; i used this with the previous Pods version), but getTotalRows thinks that $pod4 is not even an uplevel $pod3 (5 rows, as you see), but the first initialized $pod1.
p.s. there is another initialized pod on this page before pasted code, but it calls for a specific entry (provides only one result) and doesn't affect anyhow.
2 Answers
Oh, this is a bug... thanks for reporting! In pods/functions.php, on this line:
if ('SELECT FOUND ROWS()' != $sql) {
The fix is to add an underscore between FOUND and ROWS().
edited Jul 9 '10 at 2:39
Thank you :)
update: that most possibly is my coding bug - the provided template now shows
Link Category: Development, rows: 39 // that's total amount of link records Link Category: Forums, rows: 1 Link Category: Friends, rows: 1 Link Category: Inspirers, rows: 1 Link Category: Labels, rows: 1
The template that got broken earlier reports now correct amount of rows for three categories, so i guess it's just incorrect "where" in findRecords in my template.
edited Jul 9 '10 at 3:42


