3070 Posts in 869 Topics by 651 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 593 Views |
-
SS3 datamodel relation filters

1 August 2012 at 2:12am
Hello all,
I just try to figure out the SS3 Relation filters as described here:
http://doc.silverstripe.org/framework/en/topics/datamodelThere is one example which does not seem to work:
$members = Member::get()->filter(array(
'Groups.Title:StartsWith' => array('A', 'B'),
));It should return all members in groups whose names start with 'A' or 'B'... but it does not.
For sure in my database is a group with title starting with 'A': Administratoren
Has anyone already experience with that?
Kind regards,
Florian -
Re: SS3 datamodel relation filters

18 August 2012 at 2:46am
similar problem here.
given 2 classes:
Card many_many Tags
Tag belongs_many_many Cardsboth classes have a Title field; there are multiple Card objects linked to a tag with Title 'test'
some 'relation filters' i tried (none of them working):
$cards = Card::get()->filter(array(
'Tags.Title' => 'test'
)); //throws an error$cards = Card::get()->filter(array(
'Tags.Title' => array('test')
)); //throws an error$cards = Card::get()->filter(array(
'Tags.Title:StartsWith' => array('test')
)); //no results returnedthe only filter i got to work is the following:
$cards = Card::get()->filter(array(
'Tags.Title:ExactMatch' => 'test'
));looks like this thing is rather buggy?
-
Re: SS3 datamodel relation filters

22 August 2012 at 3:33am Last edited: 22 August 2012 3:41am
Hello guys,
I was also trying to use this relation filtering. Then I found this post, I have tried like schellmax and nothing. I guess I am doing something wrong with the names. Because is the same structure as its describe here.
Dataobject dLab
static $many_many = array(
'Persons' => 'dPerson'
);
Dataobject dPerson
static $belongs_many_many= array(
'Labs' => 'dLab'
);
Relation table is name "dLab_Persons"
Then I use:
$children = dLab::get()->filter(array(
'dPerson.firstname:ExactMatch' => 'Matthias'
));
Do you see something wrong??
-
Re: SS3 datamodel relation filters

22 August 2012 at 4:01am
@Bolixe: in your case it should be
<pre>
$children = dLab::get()->filter(array(
'Persons.firstname:ExactMatch' =>'Matthias'
));
</pre>note it's 'Persons.firstname', not 'dPerson.firstname'
but no info yet about the other filters...
-
Re: SS3 datamodel relation filters

22 August 2012 at 4:05am
One easy way to find out if the query works, it to append ?showqueries=1 to your URL, and see if the filters are applies at all.
Anyway, I believe this feature is only working rather recently...
-
Re: SS3 datamodel relation filters

22 August 2012 at 9:14pm
Yeah, I tried with this code schellmax. But I think could be because of the classes I have.
dLab and dPersons which are related, extends to MyDataObject which I created it, and then this one extend to DataObject from the core.
So do you think could be because this MyDataObject class should be include in the filter of the query?? It came to my mind tonight in dreams hehehe.
Thanks for the answer
-
Re: SS3 datamodel relation filters

22 August 2012 at 9:35pm Last edited: 22 August 2012 9:35pm
it's just been confirmed by 'UncleCheese' that relation filters aren't implemented yet. i'll post a comment in the docs
see: https://groups.google.com/d/topic/silverstripe-dev/XF2OoYrwEWo/discussion
-
Re: SS3 datamodel relation filters

29 August 2012 at 10:51pm Last edited: 29 August 2012 10:51pm
Ok I have read the post yesterday. And since I only want to filter one relation I want to do by my raw sql.
I have tried SQLQuery() and buildSQL() to put this in the DataObject. But all of them are deprecated.
Did you try to use it??
| 593 Views | ||
|
Page:
1
|
Go to Top |




