Cake\ORM\Query::select PHP Method

select() public method

If you pass an instance of a Cake\ORM\Table or Cake\ORM\Association class, all the fields in the schema of the table or the association will be added to the select clause.
public select ( array | Cake\Database\ExpressionInterface | string | Table | Cake\ORM\Association $fields = [], boolean $overwrite = false )
$fields array | Cake\Database\ExpressionInterface | string | Table | Cake\ORM\Association fields to be added to the list.
$overwrite boolean whether to reset fields with passed list or not
    public function select($fields = [], $overwrite = false)
    {
        if ($fields instanceof Association) {
            $fields = $fields->target();
        }
        if ($fields instanceof Table) {
            $fields = $this->aliasFields($fields->schema()->columns(), $fields->alias());
        }
        return parent::select($fields, $overwrite);
    }

Usage Example

Example #1
1
 public function findWithCount(Query $query, array $options)
 {
     $query->select(['count' => $query->func()->count('Users.id')]);
     $query->matching('Users');
     $query->group(['UserRoles.id']);
     return $query;
 }
All Usage Examples Of Cake\ORM\Query::select