Answers.Body: <p>Your statuses are incorrect. They would be correct for many elements, but the Entry Element overwrites them to the following:</p>
  
  <pre><code>EntryModel::LIVE
  EntryModel::PENDING
  EntryModel::EXPIRED
  BaseElementModel::DISABLED
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-27T11:03:43.683Z
Answers.LastActivityDate: 2014-06-27T11:03:43.683Z
Answers.UserDisplayName: Bryan Redeagle
Body: <p>I have a built a little plugin that calls the Twitter API to add new Tweets from a user timeline as entries, so that I can return them in an ElementCriteriaModel request to be integrated with content from other Sections.</p>
  
  <p>I am trying to find out the largest tweet ID currently in the Craft system, where tweet IDs are stored as a text field against an entry, so that the next call to the Twitter API can set the sinceId field to only return tweets newer than the latest one currently stored in Craft.</p>
  
  <p>I am doing this by doing an ElementCriteriaModel call, setting the order parameter to 'tweetId desc' and then attempting to find the first() entry, to retrieve the tweetId from that entry. </p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section = 'tweet';
  $criteria-&gt;order = array('tweetId desc');
  $criteria-&gt;status = array(BaseElementModel::ENABLED, BaseElementModel::DISABLED, BaseElementModel::ARCHIVED);
  
  $latestTweet = $criteria-&gt;first();
  $latestTweetId = $latestTweet-&gt;tweetID;
  </code></pre>
  
  <p>However, when I do this, the ordering of the Tweets seems to be affected by the status of the entry. It seems to be returning the tweet with the largest ID with status DISABLED, rather than the largest ID across all stored tweets.</p>
  
  <p>Is this behaviour correct, or is there a better way to do this? I do need to be able to set certain tweets to disabled, if I don't want them shown on the front-end of the site.</p>
  
Tags: <plugin-development><entries><elementcriteriamodel><ordering>
Title: Ordering of ElementCriteriaModel with varying statuses
ThreadText: # Ordering of ElementCriteriaModel with varying statuses
  
  (Asked by: username_0 on 2014-06-27)
  
  I have a built a little plugin that calls the Twitter API to add new Tweets from a user timeline as entries, so that I can return them in an ElementCriteriaModel request to be integrated with content from other Sections.
  
  I am trying to find out the largest tweet ID currently in the Craft system, where tweet IDs are stored as a text field against an entry, so that the next call to the Twitter API can set the sinceId field to only return tweets newer than the latest one currently stored in Craft.
  
  I am doing this by doing an ElementCriteriaModel call, setting the order parameter to 'tweetId desc' and then attempting to find the first() entry, to retrieve the tweetId from that entry.
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section = 'tweet';
  $criteria->order = array('tweetId desc');
  $criteria->status = array(BaseElementModel::ENABLED, BaseElementModel::DISABLED, BaseElementModel::ARCHIVED);
  
  $latestTweet = $criteria->first();
  $latestTweetId = $latestTweet->tweetID;
  
  ```
  
  However, when I do this, the ordering of the Tweets seems to be affected by the status of the entry. It seems to be returning the tweet with the largest ID with status DISABLED, rather than the largest ID across all stored tweets.
  
  Is this behaviour correct, or is there a better way to do this? I do need to be able to set certain tweets to disabled, if I don't want them shown on the front-end of the site.
  
  **Tags:** plugin-development, entries, elementcriteriamodel, ordering
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-06-27. Score: 6 | Accepted answer
  
  Your statuses are incorrect. They would be correct for many elements, but the Entry Element overwrites them to the following:
  
  ```
  EntryModel::LIVE
  EntryModel::PENDING
  EntryModel::EXPIRED
  BaseElementModel::DISABLED
  
  ```
  
  
  ---
  
  