I'm using Kohana Query Builder and trying do next:
$query
->join(«t1», «INNER»)
->on(«t1.id»,»=»,»t2.parent_id»)
->on(«t1.id»,»=»,»t3.x_id»)
This means:
INNER JOIN t1
ON(t1.id = t2.parent_id AND t1.id = t3.x_id)
But how force to use OR instead of AND of KO3 query builder join methods?
INNER JOIN t1
ON(t1.id = t2.parent_id OR t1.id = t3.x_id)
Due to Konaha source code all on()
methods are concatinated with AND
:
// Concat the conditions "... AND ..."
$sql .= ' ON ('.implode(' AND ', $conditions).')';
So you have at least 2 ways:
Database_Query_Builder_Join
methods to support OR
concatinator(it's cheating) Use DB::expr()
as 3rd parameter to on()
method like:
->on('t1.id', '=', DB::expr('t2.parent_id OR t1.id = t3.x_id))