Joins
Joins
The steps to made joins in your query using ivory are very simple and takes just some parameters.
Example Inner Join
require_once('Operations.php');
$ivoryOrm = new Operations();
$arrSelect[] = "users.name";
$arrSelect[] = "customers.id";
$tables[] = "users";
//the method select creates the query : SELECT users.name,customers.id FROM users INNER JOIN customers ON users.id = customers.id;
$select = $ivoryOrm->select($arrSelect, $tables);
$innerJoin = $ivoryOrm->innerJoin($select, "customers","users.id", "customers.id");
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($innerJoin);
Example Left Join
require_once('Operations.php');
$ivoryOrm = new Operations();
$arrSelect[] = "users.name";
$arrSelect[] = "customers.id";
$tables[] = "users";
//the method select creates the query : SELECT SELECT users.name,customers.id FROM users LEFT JOIN customers ON users.id = customers.id;
$select = $ivoryOrm->select($arrSelect, $tables);
$leftJoin = $ivoryOrm->leftJoin($select, "customers","users.id", "customers.id");
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($leftJoin);
Example Right Join
require_once('Operations.php');
$ivoryOrm = new Operations();
$arrSelect[] = "users.name";
$arrSelect[] = "customers.id";
$tables[] = "users";
//the method select creates the query : SELECT SELECT users.name,customers.id FROM users RIGHT JOIN customers ON users.id = customers.id;
$select = $ivoryOrm->select($arrSelect, $tables);
$rightJoin = $ivoryOrm->rightJoin($select, "customers","users.id", "customers.id");
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($rightJoin);
Example Full Outer Join
require_once('Operations.php');
$ivoryOrm = new Operations();
$arrSelect[] = "users.name";
$arrSelect[] = "customers.id";
$tables[] = "users";
//the method select creates the query : SELECT SELECT users.name,customers.id FROM users FULL OUTER JOIN customers ON users.id = customers.id;
$select = $ivoryOrm->select($arrSelect, $tables);
$fullOuterJoin = $ivoryOrm->fullOuterJoin($select, "customers","users.id", "customers.id");
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($fullOuterJoin);