Count, Avg and Sum
Count, Avg and Sum
The use of Count, Avg and Sum in your query can be easily done in ivory without have to add any other field to the query methods.
Example COUNT
//import the ivory class
require_once('Operations.php');
//the instance of the ivory
$ivoryOrm = new Operations();
$arrSelect[] = "COUNT(productValue)";
$tables[] = "products";
//the method select creates the query : SELECT COUNT(productValue) FROM products;
$select = $ivoryOrm->select($arrSelect, $tables);
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($select);
Example AVG
//import the ivory class
require_once('Operations.php');
//the instance of the ivory
$ivoryOrm = new Operations();
$arrSelect[] = "AVG(productValue)";
$tables[] = "products";
//the method select creates the query : SELECT AVG(productValue) FROM products;
$select = $ivoryOrm->select($arrSelect, $tables);
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($select);
Example SUM
//import the ivory class
require_once('Operations.php');
//the instance of the ivory
$ivoryOrm = new Operations();
$arrSelect[] = "SUM(productValue)";
$tables[] = "products";
//the method select creates the query : SELECT SUM(productValue) FROM products;
$select = $ivoryOrm->select($arrSelect, $tables);
//the method runQuery is responsible to literally run your query into the database;
$result = $ivoryOrm->runQuery($select);