Answers.Body: <p>For reference, the status of all elements is stored in the "elements" table, the column is "enabled" and the valid values are 1 and 0. Entry, Category, Matrix, Asset and all other elements will have their id as a foreign key linked to this table</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-19T20:24:15.470Z
Answers.Text: Ah, OK, so it looks like the id in the "entries" table is the same as the id in the "elements" table. That leaves me with:         `$cal->occurrences = (new Query()) ->select('*') ->from("myTable") ->leftJoin('craft_elements', 'myTable.event_id = craft_elements.id') ->Where("craft_elements.enabled = '1'") ->andWhere(...)->all();`  which works perfectly. Thank you!
Answers.UserDisplayName: kr37
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-19T16:16:12.947Z
Answers.LastActivityDate: 2019-08-19T16:16:12.947Z
Answers.UserDisplayName: Nick
Answers.Body: <p>Is this Craft 2 or Craft 3?</p>
  
  <p>There are a few of ways to get entries but basically you could do something like (Craft 3)</p>
  
  <pre><code>use craft\elements\Entry;
  
  $entries = Entry::find()-&gt;status(null)-&gt;all();
  </code></pre>
  
  <p>To find all disabled entries.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-19T13:31:29.427Z
Answers.Text: Thank you. Craft 3. I was hoping for something I could use in a `query->leftjoin('craft_entries', 'otherTable.entry_id = craft_entries.id')` sort of thing, but I suppose this info will work with a for loop to clear out the disabled ones.
Answers.UserDisplayName: kr37
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-19T08:20:43.050Z
Answers.LastActivityDate: 2019-08-19T08:20:43.050Z
Answers.UserDisplayName: foamcow
Body: <p>This seems like it should be simple to find, but where does Craft store the <em>status</em> of <strong>entries</strong> (lightswitch for enabled/disabled)?  It doesn't seem to be a column in the entries table, and I can't figure out how the other tables are linked to the entry number.</p>
  
  <p>Background: In a plug-in, I'm trying to filter a query to exclude only those that are disabled.</p>
  
Tags: <plugin-development><database>
Title: In a plugin, how to get entry status?
ThreadText: # In a plugin, how to get entry status?
  
  (Asked by: username_0 on 2019-08-16)
  
  This seems like it should be simple to find, but where does Craft store the *status* of **entries** (lightswitch for enabled/disabled)? It doesn't seem to be a column in the entries table, and I can't figure out how the other tables are linked to the entry number.
  
  Background: In a plug-in, I'm trying to filter a query to exclude only those that are disabled.
  
  **Tags:** plugin-development, database
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-08-19. Score: 2 | Accepted answer
  
  For reference, the status of all elements is stored in the "elements" table, the column is "enabled" and the valid values are 1 and 0. Entry, Category, Matrix, Asset and all other elements will have their id as a foreign key linked to this table
  
  > **Comments:**
  > **username_0**: Ah, OK, so it looks like the id in the "entries" table is the same as the id in the "elements" table. That leaves me with:         `$cal->occurrences = (new Query()) ->select('*') ->from("myTable") ->leftJoin('craft_elements', 'myTable.event_id = craft_elements.id') ->Where("craft_elements.enabled = '1'") ->andWhere(...)->all();`  which works perfectly. Thank you!  
  
  ---
  
  ### Answer by username_2 on 2019-08-19. Score: 2
  
  Is this Craft 2 or Craft 3?
  
  There are a few of ways to get entries but basically you could do something like (Craft 3)
  
  ```
  use craft\elements\Entry;
  
  $entries = Entry::find()->status(null)->all();
  
  ```
  
  To find all disabled entries.
  
  > **Comments:**
  > **username_0**: Thank you. Craft 3. I was hoping for something I could use in a `query->leftjoin('craft_entries', 'otherTable.entry_id = craft_entries.id')` sort of thing, but I suppose this info will work with a for loop to clear out the disabled ones.  
  
  ---
  
  