Answers.Body: <p>Fields in craft that are not element is query by something called element criteria model.
  In twig you do:</p>
  
  <pre><code>{% set result = craft.entries({
         section: 'boxes'
         orderBy: 'dateCreated asc'
         year: year,
         quarter： quarter
  }).all() %}
  </code></pre>
  
  <p>In php</p>
  
  <pre><code> $query = [
          'year' =&gt; $year,
          'quarter' =&gt; $quarter,
      ];
   $seasonBoxesQueryObject = \craft\elements\Entry::find()
                   -&gt;section('boxes')
                   -&gt;orderBy('dateCreated asc');
   $seasonBoxesQueryObject-&gt;year = $query['year'];
   $seasonBoxesQueryObject-&gt;quarter = $query['quarter'];
   $seasonBoxes = $seasonBoxesQueryObject-&gt;all();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-16T02:43:04.957Z
Answers.Text: Thanks Parry! This code works great!
Answers.UserDisplayName: aaron.cimolini
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-16T02:40:51.457Z
Answers.LastActivityDate: 2019-07-16T02:40:51.457Z
Answers.UserDisplayName: Parry Huang
Body: <p>So I have a Entry type that has two custom fields on it. Both fields are integer fields. I'd like to make a query in PHP that gets the entries by two custom fields, both of which are integer values. Here is my code so far:</p>
  
  <pre><code>    $query = [
          'year' =&gt; $year,
          'quarter' =&gt; $quarter,
      ];
      $seasonBoxes = \craft\elements\Entry::find()
                   -&gt;section('boxes')
                   -&gt;search($query)
                   -&gt;orderBy('dateCreated asc')
                   -&gt;all();
  </code></pre>
  
  <p>Please note: $year is independent of the entry creation date so I can't use the date filters.</p>
  
Tags: <craft3><entries><custom-field>
Title: Entries search query by 2 custom fields
ThreadText: # Entries search query by 2 custom fields
  
  (Asked by: username_0 on 2019-07-15)
  
  So I have a Entry type that has two custom fields on it. Both fields are integer fields. I'd like to make a query in PHP that gets the entries by two custom fields, both of which are integer values. Here is my code so far:
  
  ```
      $query = [
          'year' => $year,
          'quarter' => $quarter,
      ];
      $seasonBoxes = \craft\elements\Entry::find()
                   ->section('boxes')
                   ->search($query)
                   ->orderBy('dateCreated asc')
                   ->all();
  
  ```
  
  Please note: $year is independent of the entry creation date so I can't use the date filters.
  
  **Tags:** craft3, entries, custom-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-07-16. Score: 2 | Accepted answer
  
  Fields in craft that are not element is query by something called element criteria model.
  In twig you do:
  
  ```
  {% set result = craft.entries({
         section: 'boxes'
         orderBy: 'dateCreated asc'
         year: year,
         quarter： quarter
  }).all() %}
  
  ```
  
  In php
  
  ```
   $query = [
          'year' => $year,
          'quarter' => $quarter,
      ];
   $seasonBoxesQueryObject = \craft\elements\Entry::find()
                   ->section('boxes')
                   ->orderBy('dateCreated asc');
   $seasonBoxesQueryObject->year = $query['year'];
   $seasonBoxesQueryObject->quarter = $query['quarter'];
   $seasonBoxes = $seasonBoxesQueryObject->all();
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_1! This code works great!  
  
  ---
  
  