ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:getmedian

getMedian

Syntax
 mixed getMedian {
       mixed string $table
       mixed string $column
       optional mixed string $where
}

Returns the median value of $column for $table, or false if an error occurs.

The $where clause is optional, but if used, the WHERE statement must include the requested column as in “WHERE name > 'A'”. If an error occurs, false is returned.


Usage

/*
 * Assumed database connection in $db
*/
$table = 'zip_codes';
$column = 'population';
 
$medianPopulation = $db->getMedian($table,$column);
v5/reference/connection/getmedian.txt · Last modified: 2016/01/17 01:03 by mnewnham