1

I've implemented hook_views_query_alter($view, $query) where I'm replacing a field with a subquery (which returns a single COUNT value). However, even though it works very well to replace the field with a subquery, I'm having trouble adding one or more arguments to that subquery. Say I've got this query :

SELECT tid, (SELECT COUNT(*) FROM {download} AS d WHERE d.tid = t.tid AND d.updated > :timestamp) AS downloads FROM {track} AS t

I'd like to get a track and the number of downloads for that track after a certain point in time. I would thus need to set the ':timestamp' argument for the query. However, I can't figure out how to do that for Views.

Does anyone have experience with this? Either how to provide a subquery as a field (and not condition as in "WHERE) or how to just set an extra argument directly on the $query object.

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.