CakePHP SQL Where Count IS

In CakePHP I am trying to make it so that I can count how many instances there are (in this case searchterm) that I can only select that term if there are more than 10 instances.

I have tried this:

 $results = $this->Search->find('all',
            array('fields' => array('Search.searchterm'),

                'conditions' => array(


                    array('Search.searchterm LIKE' =>  $this->request->query['term'] . '%'),
                    array('count(Search.searchterm)' => '10'),

              ),

                'group' => array('Search.searchterm'),
                'limit' => 15,

    ));

So in this example I am trying to select all search terms where there are 10 instances but I can't get it to work.

Is it possible?

Answers


Do a find('count') instead:

$results = $this->Search->find('count',
    'conditions' => array(
        array('Search.searchterm LIKE' =>  $this->request->query['term'] . '%'),
    ),
));

And read the manual about the finds.


Need Your Help

users unable to login to Plone site

plone plone-4.x

Here is the problem that I'm having. Often times, I cannot login to my Plone site. Other users have the same issue as well. Basically what happens is that when I click "Log In", the web page just

How to pass Model and json object to controller Action

json asp.net-mvc-3 entity-framework-4.1

I looked for a long time for a solution to this problem but I cant find anything yet. I have defined a strong type as the model of a controller/view that I'm using; the problem is that the model