forked from koala-framework/koala-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroupConcat.php
51 lines (46 loc) · 1.26 KB
/
GroupConcat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
class Kwf_Model_Select_Expr_GroupConcat implements Kwf_Model_Select_Expr_Interface
{
private $_field;
private $_separator;
public function __construct($field, $separator=',')
{
$this->_field = $field;
$this->_separator = $separator;
}
public function getField()
{
return $this->_field;
}
public function getSeparator()
{
return $this->_separator;
}
public function validate()
{
$this->_field->validate();
}
public function getResultType()
{
return Kwf_Model_Interface::TYPE_STRING;
}
public function toArray()
{
$field = $this->_field;
if ($field instanceof Kwf_Model_Select_Expr_Interface) $field = $field->toArray();
return array(
'exprType' => str_replace('Kwf_Model_Select_Expr_', '', get_class($this)),
'field' => $field,
'separator' => $this->_separator,
);
}
public static function fromArray(array $data)
{
$cls = 'Kwf_Model_Select_Expr_'.$data['exprType'];
$field = $data['field'];
if (is_array($field)) {
$field = Kwf_Model_Select_Expr::fromArray($field, $data['separator']);
}
return new $cls($field);
}
}