Пример #1
0
function getJoin($table1, $table2, $joinOn, $t1_constraints, $t2_constraints)
{
    $t1_q = getTableQuote($table1);
    $t2_q = getTableQuote($table2);
    $jo = getJoinOn($table1, $table2, $joinOn);
    $tables = [];
    $tables[$table1] = $t1_constraints;
    $tables[$table2] = $t2_constraints;
    $con = getConstraintsWithTables($tables);
    $t2_columns = arrayToString(getColumnNamesWithTable($table2));
    $query = "SELECT {$t1_q}.*, {$t2_columns} FROM {$t1_q} INNER JOIN {$t2_q} ON {$jo} {$con};";
    return $query;
}
Пример #2
0
function getJoin($table1, $table2, $joinOn, $t1_constraints, $t2_constraints)
{
    $t1_q = getTableQuote($table1);
    $t2_q = getTableQuote($table2);
    $jo = getJoinOn($table1, $table2, $joinOn);
    $tables = [];
    $tables[$table1] = $t1_constraints;
    $tables[$table2] = $t2_constraints;
    $con = getConstraintsWithTables($tables);
    $t2_columns = arrayToString(getColumnNamesWithTable($table2));
    $query = "SELECT " . $t1_q . ".*, " . $t2_columns . " FROM " . $t1_q . " INNER JOIN " . $t2_q . " ON " . $jo . " " . $con . ";";
    return $query;
}