Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:56:05+00:00 2026-05-23T14:56:05+00:00

I have a function in my Event model called getEvents – you can pass

  • 0

I have a function in my Event model called getEvents – you can pass limit, start and end dates, fields, event types, and event subtypes.

I read that paginate can accept all the parameters I’m using like joins, conditions, limit…etc just like a normal find can.

It returns data just fine when I don’t try to paginate. But – I’d like to be able to pass it a paginate variable to tell it instead of doing this:

$this->recursive = -1;
$data = $this->find('all', $qOptions);

to do this:

$this->recursive = -1;
$data = $this->paginate($qOptions);

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?

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.

EDIT:

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:56:05+00:00Added an answer on May 23, 2026 at 2:56 pm

    The way I figured out how I can keep my complex find in my model without having to rewrite it a second time in the controller is by passing a $paginate boolean variable.

    If $paginate is true, it returns just the options created, which can then be used in the controller’s pagination. If it’s false (meaning we don’t want to paginate), it returns the actual event results. So far this seems to be working.

    In my getEvents() function (this method is in the Events model)

        if($paginate) {
            return $qOpts; // Just return the options for the paginate in the controller to use
        } else {
            $data = $this->find('all', $qOpts); // Return the actual events
            return $data;
        }
    

    Then, in my Events/Index (events controller, index action – where I know I want pagination):

    $this->Event->recursive = -1; // (or set recursive = -1 in the appModel)
    $opts['paginate'] = true;
    
    $paginateOptions = $this->Event->getEvents($opts);
    
    $this->paginate = $paginateOptions; // Set paginate options to just-returned options
    $data = $this->paginate('Event'); // Get paginate results
    $this->set('data', $data); // Set variable to hold paginated results in view
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: $.getJSON(Featured/getEvents, function(data){ $.each(data.events, function(i,event){ var title = event.title.substr(0,20); $(#title-+i).text(Text); if
I have a function like this in actionscript3 private function uploadFile(event:MouseEvent):void { var uploader:URLRequest
Imagine I have this code: var myFunc1 = function(event) { alert(1); } var myFunc2
i have many events such as $('.hidefile').click(function (event) { On page load and on
I have the following javascript: $('#ge-display').click(function (event) { window.open('/googleearth/ge-display.php','','scrollbars=yes,menubar=no,height=650,width=1000,resizable=yes,toolbar=yes,location=no,status=no'); event.stopPropagation(); return false; }); the
I have this js code: $(#startSearch).live(click, function(event) { $(input:checkbox[name='searchId']:checked).each(function() { var searchId = $(this).val();
i have the following block of code: $(#contact_container form, #contact_details form).live( submit, function(event) {
I have a function that is triggered by the onkeydown event of a textbox.
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I have two functions in an ActionScript class, they are: private function loaderCompleteHandler(event:Event):void {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.