Improvements to on() processing for upstream to review

This commit is contained in:
Deon George 2014-02-17 11:27:39 +11:00
parent 7801c70a1b
commit 3d7ef6a32b

View File

@ -127,8 +127,21 @@ class Kohana_Database_Query_Builder_Join extends Database_Query_Builder {
$op = ' '.strtoupper($op);
}
// In case C2 is prefixed with table
$c2table = FALSE;
$parts = explode('.', $c2);
// If there are parts, we'll check that first one is the table name.
if (count($parts) == 2)
{
if ($db->list_columns($parts[0],$parts[1]))
{
$c2table = TRUE;
}
}
// Quote each of the columns used for the condition
$conditions[] = $db->quote_column($c1).$op.' '.$db->quote_column($c2);
$conditions[] = $db->quote_column($c1).$op.' '.($c2table ? $db->quote_column($c2) : $db->quote($c2));
}
// Concat the conditions "... AND ..."