Eloquent::count PHP Method

count() public static method

Retrieve the "count" result of the query.
public static count ( string $columns = '*' ) : integer
$columns string
return integer
        public static function count($columns = '*')
        {
            return \Illuminate\Database\Query\Builder::count($columns);
        }

Usage Example

コード例 #1
0
ファイル: ParseBaseController.php プロジェクト: nidalb/baas
 /**
  * @param $className
  * @param $parameters
  * @param bool $runQuery
  * @return array
  */
 public function query($className, $parameters, $runQuery = true)
 {
     // set the default parameters
     $defaultParameters = array('where' => null, 'limit' => null, 'skip' => null, 'order' => null, 'keys' => null, 'count' => null, 'include' => null);
     $parameters = array_merge($defaultParameters, $parameters);
     extract($parameters);
     // specify the selected columns
     $selected_columns = $this->select($keys);
     // eager loading functionality
     $this->with($include);
     // filtering the data
     // todo review this line
     $query = $this->object instanceof Model ? $this->object->query() : $this->object;
     $this->object = $this->where($query, $where);
     // support pagination using limit and skip (offset)
     $this->limit($limit, $skip);
     // order the result
     $this->order($order);
     if ($runQuery) {
         // prepare the json main structure
         $jsonData = array('results' => array());
         // run the query based on the above configuration
         $jsonData['results'] = $this->object->get($selected_columns);
         if (!is_null($count)) {
             // add the count index if the user ask for
             $jsonData['count'] = $this->object->count();
         }
         // return the parsed results and count if available
         return $jsonData;
     }
 }
All Usage Examples Of Eloquent::count
Eloquent