masugadesign / link-vault-craft-cms

The Link Vault download link protection plugin for Craft CMS v3.
Other
5 stars 2 forks source link

Group count error #13

Closed timprint closed 3 years ago

timprint commented 3 years ago

I have copied the code from the groupCount example in the docs as a starting point.

{% set topDownloads = craft.linkvault.groupCount('fileName', {
    'userId' : currentUser.id,
    'order' : 'census desc'
}) %}
<ol>
{% for topDownload in topDownloads %}
    <li>{{ topDownload.fileName }} ({{ topDownload.census|number_format(0) }} downloads)</li>
{% endfor %}
</ol>

I have done some test downloads and craft.linkvault.downloads and craft.linkvault.records are both working as expected but the groupCount example code above produces the following error.

Database Exception – yii\db\Exception
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'order' in 'where clause'
The SQL being executed was: SELECT `fileName`, COUNT(*) AS `census`
FROM `linkvault_downloads`
WHERE (`userId`=1) AND (`order`='census desc')
GROUP BY `fileName`
ORDER BY COUNT(*) DESC
LIMIT 100

Error Info: Array
(
    [0] => 42S22
    [1] => 1054
    [2] => Unknown column 'order' in 'where clause'
)

Any idea what could be wrong?

ryanmasuga commented 3 years ago

What version of Craft and Link Vault?

benjaminkohl commented 3 years ago

There will be a fix for this in the next release. Until then, removing that "order" parameter should prevent the error and the results will be sorted by highest count, descending by default.

timprint commented 3 years ago

Thank you. That's working. I have another question but will open a separate issue.