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 901647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:35:19+00:00 2026-05-15T15:35:19+00:00

I have a serious deadlock about my project. I am looking for a solution

  • 0

I have a serious deadlock about my project. I am looking for a solution for days but there is nothing.

My index page have 4 different mysql queries. I tried to code this at first inside 1 controller and 1 view. It was not the right way. Then somebody suggested using 4 elements with requestAction() function. It was very good at first. Then I needed mysql between command. I could not found a way for it to use with requestAction(). My question on Cakephp group still unanswered. Somebody suggested using actions in controller. But I couldn’t figure it out how to create that controller.

Please tell me what you know about it. Thanks in advance,

Here is my current post controller’s index function:

function index() {
        $posts = $this->paginate();
        if (isset($this->params['requested'])) {
            return $posts;
        } else {
            $sql = array( 'conditions' => array( 'id BETWEEN ? AND ?' => array( 286, 291 ) ) );
            $this->Post->find('all', $sql);
            $this->set('posts', $posts);
        }
}

What should I do? Should I add a new controller for rest 3 actions? Or should I do something inside index() function?

  • 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-15T15:35:20+00:00Added an answer on May 15, 2026 at 3:35 pm

    Every time I need several queries in the single controller I do this way:

    // model Foo
    function edit($id){
        $this->data = $this->Foo->read(null, $id);
        $second = $this->Foo->Foo2->find('list');
        $third = $this->Foo->Foo3->find('list');
        $this->set(compact('second', 'third')); 
    }
    

    I guess, you want to paginate on those 3 columns so the example above is not good for that.

    I think you have an error in your method. $posts is not related to your find. There should be $posts = $this->Post->find('all', $sql);. But this would not allow you to paginate on the result. Take a look at Custom Query Pagination in the manual. Maybe this would work for you:

    function index(){
        if(!isset($this->params['requested'])) {
            $this->paginate = array('Post' => array(
                'conditions' => array('id BETWEEN ? AND ?' => array(286, 291))
            ));
        }
        $this->set('posts', $this->paginate());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

GAE recommends using JDO/JPA. But I have serious question about using OODB like them.
I have a serious performance issue about mysql. The storage engine is myisam. I
I have this serious: I have ASP.NET page, This page contents Update panel with
I have a serious issue with Liferay 6.1 themes , I know well about
I have some serious issues...I need to build a project from another developer in
I have serious problem, I have deleted Java project from Eclipse and I don't
I have a serious question for you guys. I am working on a project
i have very serious problem if any tech expert can help...thank you in advance..
I have a serious probleam with my Eclipse Plugin.. My plugin depends on another
I have a serious problem. One of our servers crashed. Now I reinstalled the

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.