ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.arWhere.php
Go to the documentation of this file.
1<?php
2require_once(dirname(__FILE__) . '/../Statement/class.arStatement.php');
3
10class arWhere extends arStatement {
11
12 const TYPE_STRING = 1;
13 const TYPE_REGULAR = 2;
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 if ($this->getType() == self::TYPE_REGULAR) {
50 $arField = $ar->getArFieldList()->getFieldByName($this->getFieldname());
51 if ($arField instanceof arField) {
52 $type = $arField->getFieldType();
53 $statement = $ar->getConnectorContainerName() . '.' . $this->getFieldname();
54 } else {
55 $statement = $this->getFieldname();
56 }
57
58 if (is_array($this->getValue())) {
59 if (in_array($this->getOperator(), array( 'IN', 'NOT IN', 'NOTIN' ))) {
60 $statement .= ' ' . $this->getOperator() . ' (';
61 } else {
62 $statement .= ' IN (';
63 }
64 $values = array();
65 foreach ($this->getValue() as $value) {
66 $values[] = $ar->getArConnector()->quote($value, $type);
67 }
68 $statement .= implode(', ', $values);
69 $statement .= ')';
70 } else {
71 if ($this->getValue() === NULL) {
72 $operator = 'IS';
73 if (in_array($this->getOperator(), array('IS', 'IS NOT'))) {
74 $operator = $this->getOperator();
75 }
76 $this->setOperator($operator);
77 }
78 $statement .= ' ' . $this->getOperator();
79 $statement .= ' ' . $ar->getArConnector()->quote($this->getValue(), $type);
80 }
82 }
83
84 return $this->getStatement();
85 }
86
87
91 public function setFieldname($fieldname) {
92 $this->fieldname = $fieldname;
93 }
94
95
99 public function getFieldname() {
100 return $this->fieldname;
101 }
102
103
107 public function setOperator($operator) {
108 $this->operator = $operator;
109 }
110
111
115 public function getOperator() {
116 return $this->operator;
117 }
118
119
123 public function setValue($value) {
124 $this->value = $value;
125 }
126
127
131 public function getValue() {
132 return $this->value;
133 }
134
135
139 public function setType($type) {
140 $this->type = $type;
141 }
142
143
147 public function getType() {
148 return $this->type;
149 }
150
151
155 public function setStatement($statement) {
156 $this->statement = $statement;
157 }
158
159
163 public function getStatement() {
164 return $this->statement;
165 }
166
167
171 public function setLink($link) {
172 $this->link = $link;
173 }
174
175
179 public function getLink() {
180 return $this->link;
181 }
182}
183
184?>
Class ActiveRecord.
Class arField.
Class arStatement.
Class arWhere.
setStatement($statement)
setOperator($operator)
setFieldname($fieldname)
setType($type)
setLink($link)
setValue($value)
const TYPE_STRING
asSQLStatement(ActiveRecord $ar)
@description Build WHERE Statement
const TYPE_REGULAR