Answers.Body: <p>By default, Craft sets a limit of 100. Set it to null: <code>limit(null)</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-27T03:49:28.360Z
Answers.LastActivityDate: 2016-07-27T03:49:28.360Z
Answers.UserDisplayName: awcross
Answers.Body: <p>Craft imposes a default limit of 100 for element queries. To disable this you need to specify a limit of <code>null</code>.</p>
  
  <pre><code>$criteria-&gt;limit = null;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-27T07:16:02.857Z
Answers.Text: `$criteria->limit = -1` also works :) `null` is more clear, though.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-27T03:50:04.143Z
Answers.LastActivityDate: 2016-07-27T06:31:59.620Z
Answers.LastEditDate: 2016-07-27T06:31:59.620Z
Answers.UserDisplayName: Ben Fleming
Body: <p>I am trying to export data from a database to a csv file, I am using the code below to retrieve the data from the DB, but it only returns 100 rows, how can I fix that?</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section = 'educators';
  $query = craft()-&gt;elements-&gt;buildElementsQuery($criteria);
  $query-&gt;order('title asc');
  $queryResults = $query-&gt;queryAll();
  $educators = EntryModel::populateModels($queryResults);
  
  foreach ($educators as $educator) {
     //Write to file
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-27T07:13:47.767Z
Comments.Text: Your code could be simplified by adding an array as a second parameter to `getCriteria()`, i.e. `$criteria = craft()->elements->getCriteria(ElementType::Entry, ['section' => 'educators', 'order' => 'title asc', 'limit' => null]);` and then just `$educators = $criteria->find();` – in other words; you don't need the calls to `buildElementsQuery()` and `queryAll()` in this particular instance, and `$criteria->find()` will actually return an array of EntryModels so there's no need to manually populate those.
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Tags: <database><queries>
Title: Query only returning 100 records at a time?
ThreadText: # Query only returning 100 records at a time?
  
  (Asked by: username_0 on 2016-07-27)
  
  I am trying to export data from a database to a csv file, I am using the code below to retrieve the data from the DB, but it only returns 100 rows, how can I fix that?
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section = 'educators';
  $query = craft()->elements->buildElementsQuery($criteria);
  $query->order('title asc');
  $queryResults = $query->queryAll();
  $educators = EntryModel::populateModels($queryResults);
  
  foreach ($educators as $educator) {
     //Write to file
  }
  
  ```
  
  **Tags:** database, queries
  
  > **Comments:**
  > **username_1**: Your code could be simplified by adding an array as a second parameter to `getCriteria()`, i.e. `$criteria = craft()->elements->getCriteria(ElementType::Entry, ['section' => 'educators', 'order' => 'title asc', 'limit' => null]);` and then just `$educators = $criteria->find();` – in other words; you don't need the calls to `buildElementsQuery()` and `queryAll()` in this particular instance, and `$criteria->find()` will actually return an array of EntryModels so there's no need to manually populate those.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2016-07-27. Score: 10 | Accepted answer
  
  Craft imposes a default limit of 100 for element queries. To disable this you need to specify a limit of `null`.
  
  ```
  $criteria->limit = null;
  
  ```
  
  > **Comments:**
  > **username_1**: `$criteria->limit = -1` also works :) `null` is more clear, though.  
  
  ---
  
  ### Answer by username_2 on 2016-07-27. Score: 5
  
  By default, Craft sets a limit of 100. Set it to null: `limit(null)`.
  
  
  ---
  
  