andrewscofield / parse.com-php-library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to just have the number of records and not all records ?

Wanted33 opened this issue · comments

Hello,

I've seen that there is the possibility to get number of records in class. So i've tried to get the number of records in class of many many records but the request return all the records and no the number of records. I know i can get the number of records if i use php function like sizeof() but i can't get all the records and count the length of array just for get the number of records.

So i also try to use this method :

$parseQueryComments = new parseQuery('comments');
$params = array(
'limit' => 0,
'count' => 1
);
$resultComments = $parseQueryComments->find($params);

And this method :

$parseQueryComments = new parseQuery('comments');
$resultComments = $parseQueryComments->getCount();

But with this 2 methods when i print $resultComments i have all records details. So it's possible to just have the number of records and not all the records ?

Thanks :)

you have to do it like this :

$parseQueryComments = new parseQuery('comments');
$parseQueryComments->setCound(true);
$parseQueryComments->setLimit(1);
$resultComments = $parseQueryComments->find($params);

but you have to check for a fix with the setCount function

  //setting this to 1 by default since you'd typically only call this function if you were wanting to turn it on
    public function setCount($bool=1){
        if(is_bool($bool)){
          $this->_count = $bool;
        }
        else{
          $this->throwError('setCount requires a boolean paremeter');
        }    
    }

Thank you , it's perfect :-)