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)?

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);
  • 1
    But at the end of the page in the link below limit function is used. drupal.org/node/1060924#comment-6426246 – harshal Sep 2 '13 at 7:25
  • 1
    ok. got it , it is usable only for 'pager default' – harshal Sep 2 '13 at 7:28
  • 1
    Exactly, just what they say there "looks like it chains with the above, but that's an illusion!" – Mołot Sep 2 '13 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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