コード例 #1
0
ファイル: Query.php プロジェクト: icanboogie/activerecord
 /**
  * Handle all the computations.
  *
  * @param string $method
  * @param string $column
  *
  * @return int|array
  */
 private function compute($method, $column)
 {
     $query = 'SELECT ';
     if ($column) {
         if ($method == 'COUNT') {
             $query .= "`{$column}`, {$method}(`{$column}`)";
             $this->group($column);
         } else {
             $query .= "{$method}(`{$column}`)";
         }
     } else {
         $query .= $method . '(*)';
     }
     $query .= ' AS count ' . $this->render_from() . $this->render_main();
     $query = $this->model->query($query, $this->args);
     if ($method == 'COUNT' && $column) {
         return $query->fetchAll(\PDO::FETCH_KEY_PAIR);
     }
     return (int) $query->rc;
 }