DAverage
extends DatabaseAbstract
in package
Table of Contents
Methods
- evaluate() : string|int|float
- DAVERAGE.
- fieldExtract() : int|null
- fieldExtract.
- filter() : array<string|int, mixed>
- filter.
- getFilteredColumn() : array<string|int, mixed>
- buildCondition() : string
- buildQuery() : string
- executeQuery() : array<string|int, mixed>
- processCondition() : string
Methods
evaluate()
DAVERAGE.
public
static evaluate(array<string|int, mixed> $database, null|array<string|int, mixed>|int|string $field, array<string|int, mixed> $criteria) : string|int|float
Averages the values in a column of a list or database that match conditions you specify.
Excel Function: DAVERAGE(database,field,criteria)
Parameters
- $database : array<string|int, mixed>
-
The range of cells that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
- $field : null|array<string|int, mixed>|int|string
-
Indicates which column is used in the function. Enter the column label enclosed between double quotation marks, such as "Age" or "Yield," or a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
- $criteria : array<string|int, mixed>
-
The range of cells that contains the conditions you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
Return values
string|int|floatfieldExtract()
fieldExtract.
protected
static fieldExtract(array<string|int, mixed> $database, mixed $field) : int|null
Extracts the column ID to use for the data field.
Parameters
- $database : array<string|int, mixed>
-
The range of cells that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
- $field : mixed
-
Indicates which column is used in the function. Enter the column label enclosed between double quotation marks, such as "Age" or "Yield," or a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
Return values
int|nullfilter()
filter.
protected
static filter(array<string|int, mixed> $database, array<string|int, mixed> $criteria) : array<string|int, mixed>
Parses the selection criteria, extracts the database rows that match those criteria, and returns that subset of rows.
Parameters
- $database : array<string|int, mixed>
-
The range of cells that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
- $criteria : array<string|int, mixed>
-
The range of cells that contains the conditions you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
Return values
array<string|int, mixed>getFilteredColumn()
protected
static getFilteredColumn(array<string|int, mixed> $database, int|null $field, array<string|int, mixed> $criteria) : array<string|int, mixed>
Parameters
- $database : array<string|int, mixed>
- $field : int|null
- $criteria : array<string|int, mixed>
Return values
array<string|int, mixed>buildCondition()
private
static buildCondition(mixed $criterion, string $criterionName) : string
Parameters
- $criterion : mixed
- $criterionName : string
Return values
stringbuildQuery()
private
static buildQuery(array<string|int, mixed> $criteriaNames, array<string|int, mixed> $criteria) : string
Parameters
- $criteriaNames : array<string|int, mixed>
- $criteria : array<string|int, mixed>
Return values
stringexecuteQuery()
private
static executeQuery(array<string|int, mixed> $database, string $query, array<string|int, mixed> $criteria, array<string|int, mixed> $fields) : array<string|int, mixed>
Parameters
- $database : array<string|int, mixed>
- $query : string
- $criteria : array<string|int, mixed>
- $fields : array<string|int, mixed>
Return values
array<string|int, mixed>processCondition()
private
static processCondition(string $criterion, array<string|int, mixed> $fields, array<string|int, mixed> $dataValues, string $conditions) : string
Parameters
- $criterion : string
- $fields : array<string|int, mixed>
- $dataValues : array<string|int, mixed>
- $conditions : string