[eluser]Maglok[/eluser]
Hey all! Still using datamapper. still awesome. I have now gotten to a situation I don't know how to deal with.
I have a object with some relations: A project with a domain, department, status. These are thus all different tables.
I can do the following:
Code:
$this->where_related_domain('id', 5);
This works swimmingly, does a join and then a where with a domain.id = 5.
Thing is I want to stack AND and OR.
Code:
where (domain.id = 5 OR domain.id = 7) AND (department.id = 3 OR department.id =5)
I would normally solve that by writing my own where like so:
Code:
$this->where("(domain.id= '5' OR domain.id = '7') AND (department.id = 3 OR department.id = 5));
Thing is, this a relation so that won't work cause there is no join yet. I can use it like this:
Code:
$this->where_related_domain("(domain.id= '5' OR domain.id = '7') AND (department.id = 3 OR department.id = 5));
But that brings all kinds of nightmares with it.
Is there anyway in Datamapper to do this without resorting to writing the entire query through $this->query();?