Relational
Relational copied to clipboard
How do you tackle nested wheres
things like where foo=1 and (where bar=0 or baz=0)
?
Using the Sql
class as this:
$this->object->select('*')->from('table')->where($data[0])->and_($data[1])->or($data[2])->_()
Leads to:
"SELECT * FROM table WHERE (a = ? OR b = ?) AND (c = ? OR d = ?)"
That's from our unit tests: https://github.com/Respect/Relational/blob/develop/tests/library/Respect/Relational/SqlTest.php#L294
It is not currently supported on the Mapper though, just Respect\Relational\Db
and Respect\Relational\Sql
.
This can be a new feature to the Mapper?
How to use IN
operation?
SELECT * FROM table WHERE id IN (1,2,3,4,5)
@amdrade
This can help you: https://github.com/Respect/Relational/blob/master/tests/library/Respect/Relational/SqlTest.php#L72-L78
Thanks @felipecwb !!