ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.arWhere.php
Go to the documentation of this file.
1 <?php
2 require_once(dirname(__FILE__) . '/../Statement/class.arStatement.php');
3 
10 class arWhere extends arStatement
11 {
12  const TYPE_STRING = 1;
13  const TYPE_REGULAR = 2;
17  protected $type = self::TYPE_REGULAR;
21  protected $fieldname = '';
25  protected $value;
29  protected $operator = '=';
33  protected $statement = '';
37  protected $link = 'AND';
38 
39 
48  public function asSQLStatement(ActiveRecord $ar)
49  {
50  if ($this->getType() == self::TYPE_REGULAR) {
51  $arField = $ar->getArFieldList()->getFieldByName($this->getFieldname());
52  if ($arField instanceof arField) {
53  $type = $arField->getFieldType();
54  $statement = $ar->getConnectorContainerName() . '.' . $this->getFieldname();
55  } else {
56  $statement = $this->getFieldname();
57  }
58 
59  if (is_array($this->getValue())) {
60  if (in_array($this->getOperator(), array( 'IN', 'NOT IN', 'NOTIN' ))) {
61  $statement .= ' ' . $this->getOperator() . ' (';
62  } else {
63  $statement .= ' IN (';
64  }
65  $values = array();
66  foreach ($this->getValue() as $value) {
67  $values[] = $ar->getArConnector()->quote($value, $type);
68  }
69  $statement .= implode(', ', $values);
70  $statement .= ')';
71  } else {
72  if ($this->getValue() === null) {
73  $operator = 'IS';
74  if (in_array($this->getOperator(), array('IS', 'IS NOT'))) {
75  $operator = $this->getOperator();
76  }
77  $this->setOperator($operator);
78  }
79  $statement .= ' ' . $this->getOperator();
80  $statement .= ' ' . $ar->getArConnector()->quote($this->getValue(), $type);
81  }
82  $this->setStatement($statement);
83  }
84 
85  return $this->getStatement();
86  }
87 
88 
92  public function setFieldname($fieldname)
93  {
94  $this->fieldname = $fieldname;
95  }
96 
97 
101  public function getFieldname()
102  {
103  return $this->fieldname;
104  }
105 
106 
110  public function setOperator($operator)
111  {
112  $this->operator = $operator;
113  }
114 
115 
119  public function getOperator()
120  {
121  return $this->operator;
122  }
123 
124 
128  public function setValue($value)
129  {
130  $this->value = $value;
131  }
132 
133 
137  public function getValue()
138  {
139  return $this->value;
140  }
141 
142 
146  public function setType($type)
147  {
148  $this->type = $type;
149  }
150 
151 
155  public function getType()
156  {
157  return $this->type;
158  }
159 
160 
164  public function setStatement($statement)
165  {
166  $this->statement = $statement;
167  }
168 
169 
173  public function getStatement()
174  {
175  return $this->statement;
176  }
177 
178 
182  public function setLink($link)
183  {
184  $this->link = $link;
185  }
186 
187 
191  public function getLink()
192  {
193  return $this->link;
194  }
195 }
Class arField.
setFieldname($fieldname)
Class ActiveRecord.
Class arWhere.
setStatement($statement)
asSQLStatement(ActiveRecord $ar)
Build WHERE Statement
Class arStatement.
const TYPE_REGULAR
setLink($link)
setType($type)
Create styles array
The data for the language used.
setValue($value)
const TYPE_STRING
setOperator($operator)