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

DataObject::get with specific Select


Go to End


3 Posts   1762 Views

Avatar
Ajaxian

Community Member, 8 Posts

5 December 2012 at 8:59pm

Hi

I read the doc, and I only saw DataObject::get(). without the ability to restrict the Select.
With get you can have access to all the fields available for the class.

But is it possible to restrict the result, I mean something like MyClass::get(array('fied1','field2')); which generates a SELECT field1, filed2 whereas withe the get() you have SELECT *

I do not see this possibility in the Doc/Api. Is there a way to do this ?

Thanks

Avatar
Willr

Forum Moderator, 5523 Posts

8 December 2012 at 4:49pm

No not with the ORM but you could bypass the ORM and use SQLQuery if you don't want to work with full objects.

http://doc.silverstripe.org/framework/en/reference/sqlquery

Avatar
Ajaxian

Community Member, 8 Posts

8 December 2012 at 7:34pm

Thanks Willr