Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group count error #13

Closed
timprint opened this issue Jan 25, 2021 · 3 comments
Closed

Group count error #13

timprint opened this issue Jan 25, 2021 · 3 comments
Assignees

Comments

@timprint
Copy link

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
Copy link
Member

What version of Craft and Link Vault?

@benjaminkohl
Copy link
Contributor

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants