Hello, I’ve a simple database query that works in phpadmin but doesn’t find any results when in a snippet. The only difference between the two tests is that I replace $LTitle with the actual search term in the phpadmin test.
The snippet checks if a tv in parent 204 has the same value as the current longtitle, and if it does it runs a ditto chunk. Snippet call:
<?php
$o = " ";
$LTitle = $modx->documentObject['longtitle'];
$result = $modx->db->query( 'SELECT value FROM `modx_site_tmplvar_contentvalues` LEFT JOIN modx_site_content ON modx_site_content.id = modx_site_tmplvar_contentvalues.contentid
WHERE value = "$LTitle" AND parent = 204 LIMIT 1' );
$total_rows = $modx->db->getRecordCount( $result );
if( $total_rows == 1 ) {
$o = "{{ditto_assoc_reviews}}";
return $o; }
else
$o = "no results found";
return $o;
?>
Chunk ditto_assoc_reviews:
<h3>Reviews</h3><ul>
[!Ditto? &parents=`204` &tpl=`book_review_list` &localFilterDelimiter=`,,` &noResults=`No reviews` &filter=`tvbook_title,,[*longtitle*],,7` &orderBy=`longtitle ASC`!]
</ul>
What mistake have I made?