Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Bug in SQLQuery::lastRow()?


Go to End


2 Posts   1350 Views

Avatar
juergr

Community Member, 17 Posts

3 December 2012 at 11:12pm

Im working on a project and try to get the last element of a DataList:

  $object->Childeren()->last();

If the list is empty, I get the following error:


[User Error] Uncaught InvalidArgumentException: SQLQuery::setLimit() only takes positive values

I have attached an image with the full output.

Is it possible that this is a bug or do I realy have to check if the list is empty before i call last()?

Attached Files
Avatar
Willr

Forum Moderator, 5523 Posts

5 December 2012 at 9:02pm

Might be good to write up a test case and submit a fix.