joinkohanaquery-builderkohana-3.3

Kohana 3. Join with multiple condition using OR


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)

Solution

  • 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: