title: Paginate from within a model in CakePHP
body: <p>I have a function in my <code>Event</code> model called <code>getEvents</code> - you can pass limit, <code>start</code> and <code>end</code> dates, <code>fields</code>, <code>event</code> <code>types</code>, and event <code>subtypes</code>.</p>
  
  <p>I read that <code>paginate</code> can accept all the parameters I'm using like <code>joins</code>, <code>conditions</code>, <code>limit</code>...etc just like a normal <code>find</code> can.</p>
  
  <p>It returns data just fine when I don't try to paginate.  But - I'd like to be able to pass it a <code>paginate</code> variable to tell it instead of doing this:</p>
  
  <pre><code>$this-&gt;recursive = -1;
  $data = $this-&gt;find('all', $qOptions);
  </code></pre>
  
  <p>to do this:</p>
  
  <pre><code>$this-&gt;recursive = -1;
  $data = $this-&gt;paginate($qOptions);
  </code></pre>
  
  <p>When I try that, though, it gives me lots of errors.  I can specify the errors later if needed - for now, I guess I'm looking for - is this something that can be done?  If so, how?</p>
  
  <p>Is there another better way to do something like this?  I spent enough time making this function do just what I want, and allowing all the options passed...etc - it just seems like a waste if I can't also use it for pagination.  But - if it's not ideal, I'm ok hearing that too.  Thanks in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I'm reading other things online that say you shouldn't use paginate in your model, because it draws from URL variables, which defeats the MVC structure purpose.  This makes sense, but does that mean I have to write the same joins/queries in both model and controller?  And in every action that it's needed?</p>