Fetching rows one by one

2007-03-09 Thread Adrian Maier
Hello, The Model-find method builds a big array that contains all the tuples. Is it possible to fetch the records one by one , in order to avoid that big array to be constructed ? One possible way would be to : get the list of id's , and then traverse it and use read($id) to get only the

Re: Fetching rows one by one

2007-03-09 Thread Sergei
put $this-Model-recursive=-1; before your -find query. On 9 мар, 17:20, Adrian Maier [EMAIL PROTECTED] wrote: Hello, The Model-find method builds a big array that contains all the tuples. Is it possible to fetch the records one by one , in order to avoid that big array to be

Re: Fetching rows one by one

2007-03-09 Thread AD7six
On Mar 9, 10:20 am, Adrian Maier [EMAIL PROTECTED] wrote: Hello, The Model-find method builds a big array that contains all the tuples. Is it possible to fetch the records one by one , in order to avoid that big array to be constructed ? One possible way would be to : get the list of

Re: Fetching rows one by one

2007-03-09 Thread Adrian Maier
On 3/9/07, AD7six [EMAIL PROTECTED] wrote: Are there better ways to fetch the query result one by one ? Why do you want to, what is the goal you want to achieve? In short: I'm reading the tuples from table T1, and for each tuple i'm searching for corresponding tuple in table T2 and , if

Re: Fetching rows one by one

2007-03-09 Thread phirschybar
Take a look at this article: http://www.thinkingphp.org/2007/02/24/cake-12s-set-class-eats-arrays-for-breakfast/ Dealing with big fat arrays in Cake can be a struggle at first but using the Set::extract method can pull out a set of the data you need very elegantly. See how Felix also uses

Re: Fetching rows one by one

2007-03-09 Thread AD7six
On Mar 9, 12:02 pm, Adrian Maier [EMAIL PROTECTED] wrote: On 3/9/07, AD7six [EMAIL PROTECTED] wrote: Are there better ways to fetch the query result one by one ? Why do you want to, what is the goal you want to achieve? In short: I'm reading the tuples from table T1, and for each

Re: Fetching rows one by one

2007-03-09 Thread phirschybar
findAll($conditions = null, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null); You can specify the fields you want to return, along with conditions, limits, just like any basic query. On Mar 9, 7:39 am, Adrian Maier [EMAIL PROTECTED] wrote: On 3/9/07, phirschybar

Re: Fetching rows one by one

2007-03-09 Thread Adrian Maier
On 3/9/07, phirschybar [EMAIL PROTECTED] wrote: Take a look at this article: http://www.thinkingphp.org/2007/02/24/cake-12s-set-class-eats-arrays-for-breakfast/ Dealing with big fat arrays in Cake can be a struggle at first but using the Set::extract method can pull out a set of the data

Re: Fetching rows one by one

2007-03-09 Thread Adrian Maier
On 3/9/07, phirschybar [EMAIL PROTECTED] wrote: findAll($conditions = null, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null); You can specify the fields you want to return, along with conditions, limits, just like any basic query. I am aware that i can select

Re: Fetching rows one by one

2007-03-09 Thread Sergei
cant you just try it? -1 will fetch ONLY the fields of current model table, without any associated data. On 9 мар, 19:08, Adrian Maier [EMAIL PROTECTED] wrote: $this-Model-recursive=-1; before your -find query. -1 doesn't appear in the manual amongst the possible values of $recursive.

Re: Fetching rows one by one

2007-03-09 Thread Adrian Maier
On 3/9/07, Sergei [EMAIL PROTECTED] wrote: cant you just try it? -1 will fetch ONLY the fields of current model table, without any associated data. Oh, I understand what you mean. We are speaking of different things : you are telling me how to get no data at all. While I want all the

Re: Fetching rows one by one

2007-03-09 Thread [EMAIL PROTECTED]
As ad7six said, this should be handled in your db if at all possible. Assuming thats not possible, use limit and page arguments to work on a small subset of the data at one time. First execute a count to find out how many records your dealing with, then loop through each subset. Something like

Re: Fetching rows one by one

2007-03-09 Thread MrTufty
Nope, they definitely don't mean stored procedures. Cookxyz's answer would seem to be the most appropriate for what you're trying to do, in this case. It's how I'd do it, and it does avoid having several thousand records in memory at once... it may not be the optimal way in this case but we don't