21308 Posts in 5737 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 214 Views |
-
Custom select expression with DataObject::get()?

8 December 2012 at 5:43pm
How to add a custom field to DataObject::get()?
Example: DataObject::get()->addSelectField("CONCAT('My', 'S', 'QL')");
-
Re: Custom select expression with DataObject::get()?

10 December 2012 at 11:23pm
http://www.silverstripe.org/data-model-questions/show/21621
If you need them as actual DataObject instances, you can loop over them like this:
$query = new SQLQuery();
$query->setFrom('SomeTable');
$query->selectField("CONCAT('My', 'S', 'QL')");
$array = $query->execute();$results = array();
// Convert them from simple array items to DataObject instances
foreach ($array as $row) {
$results[] = new YourDataObject($row);
}return new ArrayList($results);
-
Re: Custom select expression with DataObject::get()?

19 December 2012 at 8:00am
Thanks, this is what I ended up using. I was just hoping that there is an easier way to add a custom select field.
| 214 Views | ||
|
Page:
1
|
Go to Top |


