21491 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 322 Views |
-
DataObject::get - Filtering by many_many relation

5 September 2011 at 10:51pm
Say I wanted to get a dataobjectset of all articles in a given category based on the relationship defined in the classes below... what would be the nicest way to do that in a DataObject::get() call?
class Article extends DataObject{
static $many_many = array(
'Categories' => 'Category'
);
}class Category extends DataObject{
static $belongs_many_many = array(
'Articles' => 'Article'
);
}Currently I have just been doing a reverse lookup like
DataObject::get_one('Category', 'URLSegment = 'cheese')->Articles();
But that is not suitable in all cases
| 322 Views | ||
|
Page:
1
|
Go to Top |

