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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:59:45+00:00 2026-05-22T11:59:45+00:00

I have a query that’s returning a LOT of results and my code is

  • 0

I have a query that’s returning a LOT of results and my code is running out of memory trying to parse the results… how can I run a query in CakePHP and just get normal results?

By parsing it I mean….

SELECT table1.*, table2.* FROM table1 INNER JOIN table2 ON table1.id = table2.table1_id

With the above query it’ll return….

array(
   0 => array(
       'table1' => array(
            'field1' => value,
            'field2' => value
       ),
       'table2' => array(
            'field1' => value,
            'field2' => value
       )
   )
)

When it parses those results into nested arrays is when it’s running out of memory…. how do I avoid this?

I couldn’t hate CakePHP any more than I do right now :-\ If the documentation was decent that would be one thing, but it’s not decent and it’s functionality is annoying.

  • 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-22T11:59:46+00:00Added an answer on May 22, 2026 at 11:59 am

    you could do:

    $list = $this->AnyModel->query("SELECT * FROM big_table");
    

    but i dont think that will solve your problem, because if you have, for exemple, 10millon rows.. php wont be able to manage an array of 10millon values…

    but you might want to read this two links to change the execution time and the memory limit.. you could also change them on your php.ini

    Good Luck!

    EDITED
    hmm thanks to your question i’ve learned something 😛 First of all, we all agree that you’re receiving that error because Cake executes the query and tries to store the results in one array but php doesn’t support an array that big so it runs out of memory and crashes.. I have never used the classic mysql_query() (i prefer PDO) but after reading the docs, it seems that mysql_query stores the results inside a resource therefore, it’s not loading the results on memory, and that allows you to loop the results (like looping though a big file). So now i see the difference… and your question is actually, this one:

    Can I stop CakePHP fetching all rows for a query?

    =) i understand your frustration with cake, sometimes i also get frustrated with it (could you believe there’s no simple way to execute a query with a HAVING clause?? u_U)

    Cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using in C# MYsql .I have query that works if I run
I have this query that returns the results by ordering it by focus.name ASC.
I have query that gives back results like this: Client1 Product1 $500 Client1 Product2
I have this query that i should make it run on SQL Azure. WITH
Have a query that is failing because the scope is running a query like
I have a query that selects the nth results (in this case the 10th)
I have a Query that's supposed to run like this - If(var = xyz)
I have query that I run on Oracle that is supposed to allow hyphen
I have a query that produces the following results: { data: [ { id:
I have a query that performs a UNION between two tables. I'm trying to

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.