original_string: public function distinct($on = [], $overwrite = false)
      {
          if ($on === []) {
              $on = true;
          } elseif (is_string($on)) {
              $on = [$on];
          }
  
          if (is_array($on)) {
              $merge = [];
              if (is_array($this->_parts['distinct'])) {
                  $merge = $this->_parts['distinct'];
              }
              $on = $overwrite ? array_values($on) : array_merge($merge, array_values($on));
          }
  
          $this->_parts['distinct'] = $on;
          $this->_dirty();
  
          return $this;
      }
code: public function distinct($on = [], $overwrite = false)
      {
          if ($on === []) {
              $on = true;
          } elseif (is_string($on)) {
              $on = [$on];
          }
  
          if (is_array($on)) {
              $merge = [];
              if (is_array($this->_parts['distinct'])) {
                  $merge = $this->_parts['distinct'];
              }
              $on = $overwrite ? array_values($on) : array_merge($merge, array_values($on));
          }
  
          $this->_parts['distinct'] = $on;
          $this->_dirty();
  
          return $this;
      }
code_tokens: public function distinct ( $ on = [ ] , $ overwrite = false ) { if ( $ on === [ ] ) { $ on = true ; } elseif ( is_string ( $ on ) ) { $ on = [ $ on ] ; } if ( is_array ( $ on ) ) { $ merge = [ ] ; if ( is_array ( $ this -> _parts [ 'distinct' ] ) ) { $ merge = $ this -> _parts [ 'distinct' ] ; } $ on = $ overwrite ? array_values ( $ on ) : array_merge ( $ merge , array_values ( $ on ) ) ; } $ this -> _parts [ 'distinct' ] = $ on ; $ this -> _dirty ( ) ; return $ this ; }
docstring: Adds a `DISTINCT` clause to the query to remove duplicates from the result set.
  This clause can only be used for select statements.
  
  If you wish to filter duplicates based of those rows sharing a particular field
  or set of fields, you may pass an array of fields to filter on. Beware that
  this option might not be fully supported in all database systems.
  
  ### Examples:
  
  ```
  // Filters products with the same name and city
  $query->select(['name', 'city'])->from('products')->distinct();
  
  // Filters products in the same city
  $query->distinct(['city']);
  $query->distinct('city');
  
  // Filter products with the same name
  $query->distinct(['name'], true);
  $query->distinct('name', true);
  ```
  
  @param array|\Cake\Database\ExpressionInterface|string|bool $on Enable/disable distinct class
  or list of fields to be filtered on
  @param bool $overwrite whether to reset fields with passed list or not
  @return $this
docstring_tokens: Adds a DISTINCT clause to the query to remove duplicates from the result set . This clause can only be used for select statements .