original_string: protected function build_query($count = false) {
          $sql = 'SELECT ';
  
          if ($count) {
              $sql .= 'COUNT(\'x\') ';
          } else {
              $sql .= implode(', ', $this->fields) . ' ';
          }
  
          $sql .= $this->from . ' ';
          $sql .= implode(' ', $this->joins) . ' ';
  
          if (!empty($this->where)) {
              $sql .= 'WHERE (' . implode(') AND (', $this->where) . ') ';
          }
  
          if (!$count && !empty($this->order)) {
              $sql .= 'ORDER BY ' . implode(', ', $this->order);
          }
  
          return $sql;
      }
code: protected function build_query($count = false) {
          $sql = 'SELECT ';
  
          if ($count) {
              $sql .= 'COUNT(\'x\') ';
          } else {
              $sql .= implode(', ', $this->fields) . ' ';
          }
  
          $sql .= $this->from . ' ';
          $sql .= implode(' ', $this->joins) . ' ';
  
          if (!empty($this->where)) {
              $sql .= 'WHERE (' . implode(') AND (', $this->where) . ') ';
          }
  
          if (!$count && !empty($this->order)) {
              $sql .= 'ORDER BY ' . implode(', ', $this->order);
          }
  
          return $sql;
      }
code_tokens: protected function build_query ( $ count = false ) { $ sql = 'SELECT ' ; if ( $ count ) { $ sql .= 'COUNT(\'x\') ' ; } else { $ sql .= implode ( ', ' , $ this -> fields ) . ' ' ; } $ sql .= $ this -> from . ' ' ; $ sql .= implode ( ' ' , $ this -> joins ) . ' ' ; if ( ! empty ( $ this -> where ) ) { $ sql .= 'WHERE (' . implode ( ') AND (' , $ this -> where ) . ') ' ; } if ( ! $ count && ! empty ( $ this -> order ) ) { $ sql .= 'ORDER BY ' . implode ( ', ' , $ this -> order ) ; } return $ sql ; }
docstring: Internal method to build the query.
  
  @param bool $count Query to count?
  @return string The SQL statement.
docstring_tokens: Internal method to build the query .