mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-12 05:22:35 +09:00
Support SELECT DISTINCT queries
This commit is contained in:
parent
e3138f7278
commit
a086c93935
2 changed files with 12 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ class Query extends VariableBase
|
||||||
public $conditions = array();
|
public $conditions = array();
|
||||||
public $groupby = null;
|
public $groupby = null;
|
||||||
public $navigation = null;
|
public $navigation = null;
|
||||||
|
public $select_distinct = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes for query generation.
|
* Attributes for query generation.
|
||||||
|
|
@ -92,6 +93,10 @@ class Query extends VariableBase
|
||||||
{
|
{
|
||||||
// Initialize the query string.
|
// Initialize the query string.
|
||||||
$result = 'SELECT ';
|
$result = 'SELECT ';
|
||||||
|
if ($this->select_distinct)
|
||||||
|
{
|
||||||
|
$result .= 'DISTINCT ';
|
||||||
|
}
|
||||||
|
|
||||||
// Compose the column list.
|
// Compose the column list.
|
||||||
$columns = array();
|
$columns = array();
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,13 @@ class DBQueryParser
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load columns.
|
// Load columns.
|
||||||
|
if ($xml->columns && $select_distinct = trim($xml->columns['distinct']))
|
||||||
|
{
|
||||||
|
if ($select_distinct === 'distinct' || toBool($select_distinct))
|
||||||
|
{
|
||||||
|
$query->select_distinct = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach ($xml->columns->column as $tag)
|
foreach ($xml->columns->column as $tag)
|
||||||
{
|
{
|
||||||
if ($tag->getName() === 'query')
|
if ($tag->getName() === 'query')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue