示例#1
0
 /**
  * Get an aggregate value.
  *
  * @param  string  $aggregate
  * @param  string  $column
  * @return mixed
  */
 private function aggregate($aggregator, $column)
 {
     $this->aggregate = compact('aggregator', 'column');
     $result = $this->connection->only($this->grammar->select($this), $this->bindings);
     // Reset the aggregate so more queries can be performed using
     // the same instance. This is helpful for getting aggregates
     // and then getting actual results.
     $this->aggregate = null;
     return $result;
 }
示例#2
0
 /**
  * Get an aggregate value.
  *
  * @param  string  $aggregator
  * @param  array   $columns
  * @return mixed
  */
 public function aggregate($aggregator, $columns)
 {
     // We'll set the aggregate value so the grammar does not try to compile
     // a SELECT clause on the query. If an aggregator is present, it's own
     // grammar function will be used to build the SQL syntax.
     $this->aggregate = compact('aggregator', 'columns');
     $sql = $this->grammar->select($this);
     $result = $this->connection->only($sql, $this->bindings);
     // Reset the aggregate so more queries can be performed using the same
     // instance. This is helpful for getting aggregates and then getting
     // actual results from the query such as during paging.
     $this->aggregate = null;
     return $result;
 }