A segment is a condition used to filter visits. They can, for example,
select visits that have a specific browser or come from a specific
country, or both.
Individual segment dimensions (such as browserCode and countryCode)
are defined by plugins. Read about the {@hook API.getSegmentDimensionMetadata}
event to learn more.
Plugins that aggregate data stored in Piwik can support segments by
using this class when generating aggregation SQL queries.
### Examples
**Basic usage**
$idSites = array(1,2,3);
$segmentStr = "browserCode==ff;countryCode==CA";
$segment = new Segment($segmentStr, $idSites);
$query = $segment->getSelectQuery(
$select = "table.col1, table2.col2",
$from = array("table", "table2"),
$where = "table.col3 = ?",
$bind = array(5),
$orderBy = "table.col1 DESC",
$groupBy = "table2.col2"
);
Db::fetchAll($query['sql'], $query['bind']);
**Creating a _null_ segment**
$idSites = array(1,2,3);
$segment = new Segment('', $idSites);
$segment->getSelectQuery will return a query that selects all visits