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

Any & All

Any & All

The steps to made a Any or All in query using ivory are very simple and uses just a few parameters.

Example ANY

require_once('Operations.php');

$ivoryOrm = new Operations();

$arrSelect2[] = "name";

$arrWhere2[] = [
    "propName" => "name",
    "fieldValue" => "Jon",
];

$tables2[] = "aditional_data";

$select2 = $ivoryOrm->select($arrSelect2, $tables2);
$select2 = $ivoryOrm->where($select2, $arrWhere2);

$arrSelect[] = "name";
$arrSelect[] = "email";

$tables[] = "users";

$arrWhere[] = [
    "propName" => "name",
    "fieldValue" => "",
    "isAny" => $select2,
];

//the method select creates the query : 
//SELECT name,email FROM users WHERE name ANY (SELECT name FROM aditional_data WHERE name = 'Jon'); 

$select = $ivoryOrm->select($arrSelect, $tables);
$selectWhere = $ivoryOrm->where($select, $arrWhere);

//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($selectWhere);

Example ALL

require_once('Operations.php');

$ivoryOrm = new Operations();

$arrSelect2[] = "name";

$arrWhere2[] = [
    "propName" => "name",
    "fieldValue" => "Jon",
];

$tables2[] = "aditional_data";

$select2 = $ivoryOrm->select($arrSelect2, $tables2);
$select2 = $ivoryOrm->where($select2, $arrWhere2);

$arrSelect[] = "name";
$arrSelect[] = "email";

$tables[] = "users";

$arrWhere[] = [
    "propName" => "name",
    "fieldValue" => "",
    "isAll" => $select2,
];

//the method select creates the query : 
//SELECT name,email FROM users WHERE name ALL (SELECT name FROM aditional_data WHERE name = 'Jon'); 

$select = $ivoryOrm->select($arrSelect, $tables);
$selectWhere = $ivoryOrm->where($select, $arrWhere);

//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($selectWhere);

← ExistsProcedures →
  • Any & All
  • Example ANY
  • Example ALL
Repository Link
Copyright © 2020 Kevin da Silva