3060 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 628 Views |
-
Excluding data from a dataobjectset

28 November 2010 at 2:56am
Is there a way to exclude a result from a dataobjectset without affecting it in the database?
I've tried remove() but this writes to the database.My scenario is as follows:
- I have a list of articles
- One of those articles flagged as "featured" will be a featured article, this will be selected at random from all articles marked as featured
- I need to get the dataobjectset of the rest of the articles, excluding the featured one -
Re: Excluding data from a dataobjectset

28 November 2010 at 8:05am
remove does work, but how about...
$newresult = new DataObjectSet();
foreach ($result as $do) {
if (!$do->Featured)
$newresult->push($do);or in the template
<% control result %>
<% if Featured != true %>
$Name
<% end_if %>
<% end_control %>or even better use the where clause of the DataOBject::get()
-
Re: Excluding data from a dataobjectset

28 November 2010 at 8:48pm
Thanks swaiba, I ended up using where after I posted. I was trying to avoid code repetition, but in this instance it was the most efficient way to do it.
| 628 Views | ||
|
Page:
1
|
Go to Top |


