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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Retrieving max value from Dataobject


Go to End


5 Posts   2832 Views

Avatar
ville

Community Member, 5 Posts

26 June 2012 at 6:51am

Hey,

I have column in a table which contains numbers. How can I retrieve the max value from that column? Do I have to use rawsql-query or is it possible to do with Dataobject::get?

Thanks in advance!

Avatar
swaiba

Forum Moderator, 1899 Posts

27 June 2012 at 2:18am

$iMax = DB::query("SELECT MAX(\"Field\") FROM \"DataObjectClassName\"")->value();

Avatar
handschaltung

Community Member, 4 Posts

26 October 2016 at 2:58am

Is the ID somewhere stored in the database?

Avatar
swaiba

Forum Moderator, 1899 Posts

26 October 2016 at 3:28am

yes the it's called "ID" in the database, it is also viewable by inspecting links in the CMS

Avatar
handschaltung

Community Member, 4 Posts

26 October 2016 at 7:34pm

I meant the maximum ID, where is that stored in the database?
Or is it stored somewhere else?

Sorry for not being precise enough...