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

Order By

AND, OR and NOT Operators

With the order by method in ivory you can create a query and even specify the type of the filter you want in your order by query(DESC/ASC).

Example DESC

//import the ivory class
require_once('Operations.php');

//the instance of the ivory
$ivoryOrm = new Operations();

//an array where you add all the field names of the fields you want to  select
$arrSelect[] = "name";
$arrSelect[] = "email";

//an array where you add all the table names you want to  select
$tables[] = "users";

//the method creates the query : SELECT name,email FROM users ORDER BY id DESC;
$select = $ivoryOrm->select($arrSelect, $tables);
$selectOrder = $ivoryOrm->order($select, $arrWhere);

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

Example ASC

require_once('Operations.php');

$ivoryOrm = new Operations();

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

$tables[] = "users";

//the method creates the query : SELECT name,email FROM users ORDER BY id ASC;
$select = $ivoryOrm->select($arrSelect, $tables);
$isDesc = false;
$selectOrder = $ivoryOrm->order($select, $arrWhere, $isDesc);

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

← And, Or and NotInsert →
  • AND, OR and NOT Operators
  • Example DESC
  • Example ASC
Repository Link
Copyright © 2020 Kevin da Silva