Ivory ORM Docs

Ivory ORM Docs

  • Docs

›SQL Syntax

SQL Syntax

  • First-Steps
  • Select
  • Select Distinct
  • Where
  • And, Or and Not
  • Order By
  • Insert
  • Update
  • Delete
  • Min and Max
  • Count, Avg and Sum
  • Like
  • In
  • Between
  • Alias
  • Joins
  • Union
  • Group By
  • Having
  • Exists
  • Any & All
  • Procedures

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);

← JoinsGroup By →
  • Union
  • Example
  • Example 2 UNION ALL
Repository Link
Copyright © 2020 Kevin da Silva