fatchAll limit

View: New views
11 Messages — Rating Filter:   Alert me  

fatchAll limit

by Jeff Surgeson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

How do I limit the number of returned records in a fetchAl()?

In the "good ol days" I would just pass a "limit" param to fetchAll along with
the other query param's

I know I am missing the obvious but cant seem to get it to work, it looks like
limit now needs a array(count, offset), please explain?

Jeff
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Jon Elofson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I just took a stab at this. Looks like you can pass either an array or
a Solar_Sql_Model_Params_Fetch object to the fetchAll() method.

I tried a quick one with an array and the only way I could get it to
work was like this:

$users = $this->_model->users->fetchAll(array(
    'limit'=>array(
        array(10,0)
    )
));

Seems like one extra dimension there. I haven't explored it much more.
But now I feel compelled.

Jon


On Mon, Sep 14, 2009 at 3:01 PM, Jeff Surgeson <solar@...> wrote:

> Hi
>
> How do I limit the number of returned records in a fetchAl()?
>
> In the "good ol days" I would just pass a "limit" param to fetchAll along with
> the other query param's
>
> I know I am missing the obvious but cant seem to get it to work, it looks like
> limit now needs a array(count, offset), please explain?
>
> Jeff
> _______________________________________________
> Solar-talk mailing list
> Solar-talk@...
> http://mailman-mail5.webfaction.com/listinfo/solar-talk
>
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Paul M Jones-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sep 14, 2009, at 16:01 , Jeff Surgeson wrote:

> Hi
>
> How do I limit the number of returned records in a fetchAl()?
>
> In the "good ol days" I would just pass a "limit" param to fetchAll  
> along with
> the other query param's
>
> I know I am missing the obvious but cant seem to get it to work, it  
> looks like
> limit now needs a array(count, offset), please explain?

The explanation is, "it wasn't working right."  ;-)

Yes, you should be able to pass just an integer to limit() and have it  
work; I have just committed a fix for it.

(FYI, you also should have been able to pass an array($limit, $offset)  
in previous versions.)

There's also page() and paging() to limit result sets; please let me  
know if those aren't working for you.




--

Paul M. Jones
http://paul-m-jones.com/




_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Anthony Gentile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ya, I ran into this as well, I currently replaced

$spec = array_pad($spec, 2, null);

with

$spec = (is_array($spec)) ? $spec : array($spec, 0) ;

until I get some feedback about intended limit syntax...mayhaps just missing a check for array

Anthony Gentile
Cell: 704.657.8550

Diese E-Mail ist vertraulich. Wenn Sie nicht der rechtmaessige Empfaenger sind, duerfen Sie den Inhalt weder kopieren noch verbreiten oder benutzen. Sollten Sie diese E-Mail versehentlich erhalten haben, senden Sie diese bitte an uns zurueck und loeschen Sie sie anschliessend.

This email is confidential. If you are not the intended recipient, you must not copy, disclose or use its contents. If you have received it in error, please inform us immediately by return email and delete the document.


On Mon, Sep 14, 2009 at 8:29 PM, Jon Elofson <jon.elofson@...> wrote:
Hi,
I just took a stab at this. Looks like you can pass either an array or
a Solar_Sql_Model_Params_Fetch object to the fetchAll() method.

I tried a quick one with an array and the only way I could get it to
work was like this:

$users = $this->_model->users->fetchAll(array(
   'limit'=>array(
       array(10,0)
   )
));

Seems like one extra dimension there. I haven't explored it much more.
But now I feel compelled.

Jon


On Mon, Sep 14, 2009 at 3:01 PM, Jeff Surgeson <solar@...> wrote:
> Hi
>
> How do I limit the number of returned records in a fetchAl()?
>
> In the "good ol days" I would just pass a "limit" param to fetchAll along with
> the other query param's
>
> I know I am missing the obvious but cant seem to get it to work, it looks like
> limit now needs a array(count, offset), please explain?
>
> Jeff
> _______________________________________________
> Solar-talk mailing list
> Solar-talk@...
> http://mailman-mail5.webfaction.com/listinfo/solar-talk
>
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk


_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Anthony Gentile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

ahh, even better.

Anthony Gentile
Cell: 704.657.8550

Diese E-Mail ist vertraulich. Wenn Sie nicht der rechtmaessige Empfaenger sind, duerfen Sie den Inhalt weder kopieren noch verbreiten oder benutzen. Sollten Sie diese E-Mail versehentlich erhalten haben, senden Sie diese bitte an uns zurueck und loeschen Sie sie anschliessend.

This email is confidential. If you are not the intended recipient, you must not copy, disclose or use its contents. If you have received it in error, please inform us immediately by return email and delete the document.


On Mon, Sep 14, 2009 at 8:42 PM, Anthony Gentile <asgentile@...> wrote:
Ya, I ran into this as well, I currently replaced

$spec = array_pad($spec, 2, null);

with

$spec = (is_array($spec)) ? $spec : array($spec, 0) ;

until I get some feedback about intended limit syntax...mayhaps just missing a check for array

Anthony Gentile
Cell: 704.657.8550

Diese E-Mail ist vertraulich. Wenn Sie nicht der rechtmaessige Empfaenger sind, duerfen Sie den Inhalt weder kopieren noch verbreiten oder benutzen. Sollten Sie diese E-Mail versehentlich erhalten haben, senden Sie diese bitte an uns zurueck und loeschen Sie sie anschliessend.

This email is confidential. If you are not the intended recipient, you must not copy, disclose or use its contents. If you have received it in error, please inform us immediately by return email and delete the document.



On Mon, Sep 14, 2009 at 8:29 PM, Jon Elofson <jon.elofson@...> wrote:
Hi,
I just took a stab at this. Looks like you can pass either an array or
a Solar_Sql_Model_Params_Fetch object to the fetchAll() method.

I tried a quick one with an array and the only way I could get it to
work was like this:

$users = $this->_model->users->fetchAll(array(
   'limit'=>array(
       array(10,0)
   )
));

Seems like one extra dimension there. I haven't explored it much more.
But now I feel compelled.

Jon


On Mon, Sep 14, 2009 at 3:01 PM, Jeff Surgeson <solar@...> wrote:
> Hi
>
> How do I limit the number of returned records in a fetchAl()?
>
> In the "good ol days" I would just pass a "limit" param to fetchAll along with
> the other query param's
>
> I know I am missing the obvious but cant seem to get it to work, it looks like
> limit now needs a array(count, offset), please explain?
>
> Jeff
> _______________________________________________
> Solar-talk mailing list
> Solar-talk@...
> http://mailman-mail5.webfaction.com/listinfo/solar-talk
>
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk



_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Paul M Jones-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 14, 2009, at 20:40 , Paul M Jones wrote:

> On Sep 14, 2009, at 16:01 , Jeff Surgeson wrote:
>
>> Hi
>>
>> How do I limit the number of returned records in a fetchAl()?
>>
>> In the "good ol days" I would just pass a "limit" param to fetchAll
>> along with
>> the other query param's
>>
>> I know I am missing the obvious but cant seem to get it to work, it
>> looks like
>> limit now needs a array(count, offset), please explain?
>
> The explanation is, "it wasn't working right."  ;-)
>
> Yes, you should be able to pass just an integer to limit() and have it
> work; I have just committed a fix for it.

OK *now* I have committed the fix.  Previous one was to branches/
unfounded.



--

Paul M. Jones
http://paul-m-jones.com/




_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Jon Elofson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am not completely convinced that it's working properly. It works
fine with a single integer, or a single element array, but if you pass
an array like array(1, 3), I would expect to get 1 row starting at row
3. When I try this, I get three rows. It seems like the limit method
is called twice. So, on the second go, limit is set to 3.

example:
$users = $this->_model->users->fetchAll(array(
    'limit'=>array(1,3)
));

If I do this in Solar_Sql_Model_Params_Fetch limit() method:
$spec = array_pad((array)$spec, 2, null);
print_r($spec); // what does $spec look like?

I get

Array
(
    [0] => 1
    [1] =>
)
Array
(
    [0] => 3
    [1] =>
)


Unless I messed something else up somewhere. Would someone be able to confirm?


Now, if I go like this:
$users = $this->_model->users->fetchAll(array(
    'limit'=>array(array(1,3)) // extra dimension
));

then the results are as expected.
Array
(
    [0] => 1
    [1] => 3
)
with only one row returned.

So, I there is still a bug, or I messed something up.
I am checking into Solar_Sql_Model's _fixFetchParams() plus
Solar_Struct and Solar_Sql_Model_Params, specifically load() and
related methods.

Jon
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Paul M Jones-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 14, 2009, at 21:53 , Jon Elofson wrote:

> I am not completely convinced that it's working properly.

You were correct not to be convinced; committed a second fix.  Let me  
know if it's still busted.  Sorry for the hassle.  :-(




--

Paul M. Jones
http://paul-m-jones.com/




_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Paul M Jones-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sep 14, 2009, at 22:02 , Paul M Jones wrote:

>
> On Sep 14, 2009, at 21:53 , Jon Elofson wrote:
>
>> I am not completely convinced that it's working properly.
>
> You were correct not to be convinced; committed a second fix.  Let me
> know if it's still busted.  Sorry for the hassle.  :-(

Third fix, 4018, in trunk.  I need to stop doing this late at  
night.  :-(




--

Paul M. Jones
http://paul-m-jones.com/




_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Jon Elofson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Woohoo! Looks like you got it. Thanks.


On Mon, Sep 14, 2009 at 9:04 PM, Paul M Jones <pmjones@...> wrote:

>
> On Sep 14, 2009, at 22:02 , Paul M Jones wrote:
>
>>
>> On Sep 14, 2009, at 21:53 , Jon Elofson wrote:
>>
>>> I am not completely convinced that it's working properly.
>>
>> You were correct not to be convinced; committed a second fix.  Let me
>> know if it's still busted.  Sorry for the hassle.  :-(
>
> Third fix, 4018, in trunk.  I need to stop doing this late at
> night.  :-(
>
>
>
>
> --
>
> Paul M. Jones
> http://paul-m-jones.com/
>
>
>
>
> _______________________________________________
> Solar-talk mailing list
> Solar-talk@...
> http://mailman-mail5.webfaction.com/listinfo/solar-talk
>
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: fatchAll limit

by Jeff Surgeson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> On Sep 14, 2009, at 20:40 , Paul M Jones wrote:
> > On Sep 14, 2009, at 16:01 , Jeff Surgeson wrote:
> >> Hi
> >>
> >> How do I limit the number of returned records in a fetchAl()?
> >>
> >> In the "good ol days" I would just pass a "limit" param to fetchAll
> >> along with
> >> the other query param's
> >>
> >> I know I am missing the obvious but cant seem to get it to work, it
> >> looks like
> >> limit now needs a array(count, offset), please explain?
> >
> > The explanation is, "it wasn't working right."  ;-)
> >
> > Yes, you should be able to pass just an integer to limit() and have it
> > work; I have just committed a fix for it.
>
> OK *now* I have committed the fix.  Previous one was to branches/
> unfounded.

That did the trick, thanks Paul :)
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk