FaaPz\PDO\Clause\Join implements QueryInterface

November 6, 2021 ยท View on GitHub

Used in Select, Update and Delete statements.

Constructor

__construct($table, Conditional $on, $type = "")

ParameterDescription
$tableThe table to join against
$onConditional to join the above table on
$typeOptional type of join to perform

Example

use FaaPz\PDO\Clause\Conditional;
use FaaPz\PDO\Clause\Join;
use FaaPz\PDO\Clause\Raw;

// ... JOIN orders ON customers.id = orders.customer_id
$statement->join(new Join("orders",
    new Conditional("customers.id",  "=", new Raw("orders.customer_id"))
);

// ... INNER JOIN orders ON customers.id = orders.customer_id
$statement->join(new Join("orders",
    new Conditional("customers.id",  "=", new Raw("orders.customer_id")),
    "INNER"
);

// ... LEFT OUTER JOIN orders ON customers.id = orders.customer_id
$statement->join(new Join("orders",
    new Conditional("customers.id",  "=", new Raw("orders.customer_id")),
    "LEFT OUTER"
);

// ... RIGHT OUTER JOIN orders ON customers.id = orders.customer_id
$statement->join(new Join("orders",
    new Conditional("customers.id",  "=", new Raw("orders.customer_id")),
    "RIGHT OUTER"
);

// ... FULL OUTER JOIN orders ON customers.id = orders.customer_id
$statement->join(new Join("orders",
    new Conditional("customers.id",  "=", new Raw("orders.customer_id")),
    "FULL OUTER"
);