Union
Union
The steps to made a union in ivory are very simple and uses just a few parameters.
Example
require_once('Operations.php');
$ivoryOrm = new Operations();
$arrSelect[] = "name";
$arrSelect[] = "email";
$tables[] = "users";
$select = $ivoryOrm->select($arrSelect, $tables);
$arrSelect2[] = "name";
$arrSelect2[] = "phone";
$tables2[] = "aditional_data";
$select2 = $ivoryOrm->select($arrSelect2, $tables2);
$query = $ivoryOrm->union($select, $select2);
//output SELECT name,email FROM users
//UNION
//SELECT name,phone FROM aditional_data;
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($query);
Example 2 UNION ALL
require_once('Operations.php');
$ivoryOrm = new Operations();
$arrSelect[] = "name";
$arrSelect[] = "email";
$tables[] = "users";
$select = $ivoryOrm->select($arrSelect, $tables);
$arrSelect2[] = "name";
$arrSelect2[] = "phone";
$tables2[] = "aditional_data";
$select2 = $ivoryOrm->select($arrSelect2, $tables2, true);
$query = $ivoryOrm->union($select, $select2);
//output SELECT name,email FROM users
//UNION ALL
//SELECT name,phone FROM aditional_data;
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($query);