2

In a query I tried using limit(1); I got a WSOD, but when I use range(0,1) I don't get any WSOD.

What is the basic difference between limit(1) and range(0, 1)?

0

1 Answer 1

2

Base difference is that range is a method of SelectQuery class, and limit isn't.

Some APIs can extend SelectQuery and add limit. For example $query->extendQuery('PagerDefault') will return object of PagerDefault class that has limit method defined.

It may result in a syntax looking like limit() is invoked on SelectQuery, when in fact it isn't:

$query = db_select('node', 'n')
      ->fields('n')
      ->condition('type','problem','=')
      ->extend('PagerDefault')
      ->limit(20);
3
  • 1
    But at the end of the page in the link below limit function is used. drupal.org/node/1060924#comment-6426246
    – harshal
    Commented Sep 2, 2013 at 7:25
  • 1
    ok. got it , it is usable only for 'pager default'
    – harshal
    Commented Sep 2, 2013 at 7:28
  • 1
    Exactly, just what they say there "looks like it chains with the above, but that's an illusion!"
    – Mołot
    Commented Sep 2, 2013 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.