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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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   1746 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...