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

Count requires conditions #1282

Closed
shopblocks opened this issue Jun 17, 2016 · 1 comment
Closed

Count requires conditions #1282

shopblocks opened this issue Jun 17, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@shopblocks
Copy link

If you don't provide conditions to a Model::count() call, then it will use group as a column name, rather than to group results.

ContentBlocks::count([
//            'conditions' => [
//                'deleted' => 0,
//            ],
            'group' => 'name',
        ]);

results in:

lithium\data\model\QueryException Object
(
    [code:protected] => 1054
    [message:protected] => SELECT COUNT(*) as count FROM `content_blocks` AS `ContentBlocks` WHERE `ContentBlocks`.`group` = 'name';: Unknown column 'ContentBlocks.group' in 'where clause'
    [string:Exception:private] => 
    [file:protected] => /var/www/vhosts/miribase/libraries/lithium/data/source/Database.php
    [line:protected] => 1557
    [trace:Exception:private] => Array

Adding the conditions will allow it work as expected.

@mariuswilms mariuswilms self-assigned this Jun 17, 2016
@mariuswilms mariuswilms added this to the 1.0 milestone Jun 17, 2016
mariuswilms added a commit that referenced this issue Jun 17, 2016
The Model $_query array was not in-sync with possible options of Query.

Fixes #1282
@mariuswilms
Copy link
Member

Thanks for reporting -- fixed in f315244

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

No branches or pull requests

2 participants