ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
arWhere Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for arWhere:
+ Collaboration diagram for arWhere:

Public Member Functions

 asSQLStatement (ActiveRecord $activeRecord, ilDBInterface $db)
 
 setFieldname (string $fieldname)
 
 getFieldname ()
 
 setOperator (string $operator)
 
 getOperator ()
 
 setValue ($value)
 
 getValue ()
 
 setType (int $type)
 
 getType ()
 
 setStatement (string $statement)
 
 getStatement ()
 
 setLink (string $link)
 
 getLink ()
 
- Public Member Functions inherited from arStatement
 asSQLStatement (ActiveRecord $activeRecord, ilDBInterface $db)
 
 getTableNameAs ()
 
 setTableNameAs (string $table_name_as)
 

Data Fields

const TYPE_STRING = 1
 
const TYPE_REGULAR = 2
 

Protected Attributes

int $type = self::TYPE_REGULAR
 
string $fieldname = ''
 
 $value
 
string $operator='='
 
string $statement = ''
 
string $link = 'AND'
 
- Protected Attributes inherited from arStatement
string $table_name_as = ''
 

Additional Inherited Members

- Protected Member Functions inherited from arStatement
 wrapFields (array $fields, ilDBInterface $db)
 
 wrapField (string $field, ilDBInterface $db)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class arWhere

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
2.0.7

Definition at line 24 of file class.arWhere.php.

Member Function Documentation

◆ asSQLStatement()

arWhere::asSQLStatement ( ActiveRecord  $activeRecord,
ilDBInterface  $db 
)
Parameters
ilDBInterface$dbBuild WHERE Statement
Exceptions
arException

Definition at line 43 of file class.arWhere.php.

References $value, ActiveRecord\getArConnector(), ActiveRecord\getArFieldList(), ActiveRecord\getConnectorContainerName(), getFieldname(), getOperator(), getStatement(), getType(), getValue(), setOperator(), and setStatement().

43  : string
44  {
45  $type = null;
46  if ($this->getType() === self::TYPE_REGULAR) {
47  $arField = $activeRecord->getArFieldList()->getFieldByName($this->getFieldname());
48  $type = 'text';
49  if ($arField instanceof arField) {
50  $type = $arField->getFieldType();
51  $statement = $activeRecord->getConnectorContainerName() . '.' . $this->getFieldname();
52  } else {
53  $statement = $this->getFieldname();
54  }
55 
56  if (is_array($this->getValue())) {
57  if (in_array($this->getOperator(), ['IN', 'NOT IN', 'NOTIN'])) {
58  $statement .= ' ' . $this->getOperator() . ' (';
59  } else {
60  $statement .= ' IN (';
61  }
62  $values = [];
63  foreach ($this->getValue() as $value) {
64  $values[] = $activeRecord->getArConnector()->quote($value, $type);
65  }
66  $statement .= implode(', ', $values);
67  $statement .= ')';
68  } else {
69  if ($this->getValue() === null) {
70  $operator = 'IS';
71  if (in_array($this->getOperator(), ['IS', 'IS NOT'])) {
72  $operator = $this->getOperator();
73  }
74  $this->setOperator($operator);
75  }
76  $statement .= ' ' . $this->getOperator();
77  $statement .= ' ' . $activeRecord->getArConnector()->quote($this->getValue(), $type);
78  }
79  $this->setStatement($statement);
80  }
81 
82  return $this->getStatement();
83  }
Class arField.
string $statement
getConnectorContainerName()
Return the Name of your Connector Table
setStatement(string $statement)
setOperator(string $operator)
+ Here is the call graph for this function:

◆ getFieldname()

arWhere::getFieldname ( )

Definition at line 90 of file class.arWhere.php.

References $fieldname.

Referenced by asSQLStatement().

90  : string
91  {
92  return $this->fieldname;
93  }
string $fieldname
+ Here is the caller graph for this function:

◆ getLink()

arWhere::getLink ( )

Definition at line 146 of file class.arWhere.php.

References $link.

146  : string
147  {
148  return $this->link;
149  }
string $link

◆ getOperator()

arWhere::getOperator ( )

Definition at line 100 of file class.arWhere.php.

Referenced by asSQLStatement().

100  : string
101  {
102  return $this->operator;
103  }
+ Here is the caller graph for this function:

◆ getStatement()

arWhere::getStatement ( )

Definition at line 136 of file class.arWhere.php.

References $statement.

Referenced by asSQLStatement().

136  : string
137  {
138  return $this->statement;
139  }
string $statement
+ Here is the caller graph for this function:

◆ getType()

arWhere::getType ( )

Definition at line 126 of file class.arWhere.php.

References $type.

Referenced by asSQLStatement().

126  : int
127  {
128  return $this->type;
129  }
+ Here is the caller graph for this function:

◆ getValue()

arWhere::getValue ( )
Returns
mixed|null

Definition at line 116 of file class.arWhere.php.

References $value.

Referenced by asSQLStatement().

117  {
118  return $this->value;
119  }
+ Here is the caller graph for this function:

◆ setFieldname()

arWhere::setFieldname ( string  $fieldname)

Definition at line 85 of file class.arWhere.php.

References $fieldname.

85  : void
86  {
87  $this->fieldname = $fieldname;
88  }
string $fieldname

◆ setLink()

arWhere::setLink ( string  $link)

Definition at line 141 of file class.arWhere.php.

References $link.

141  : void
142  {
143  $this->link = $link;
144  }
string $link

◆ setOperator()

arWhere::setOperator ( string  $operator)

Definition at line 95 of file class.arWhere.php.

Referenced by asSQLStatement().

95  : void
96  {
97  $this->operator = $operator;
98  }
+ Here is the caller graph for this function:

◆ setStatement()

arWhere::setStatement ( string  $statement)

Definition at line 131 of file class.arWhere.php.

References $statement.

Referenced by asSQLStatement().

131  : void
132  {
133  $this->statement = $statement;
134  }
string $statement
+ Here is the caller graph for this function:

◆ setType()

arWhere::setType ( int  $type)

Definition at line 121 of file class.arWhere.php.

References $type.

121  : void
122  {
123  $this->type = $type;
124  }

◆ setValue()

arWhere::setValue (   $value)
Parameters
mixed$value

Definition at line 108 of file class.arWhere.php.

References $value.

108  : void
109  {
110  $this->value = $value;
111  }

Field Documentation

◆ $fieldname

string arWhere::$fieldname = ''
protected

Definition at line 29 of file class.arWhere.php.

Referenced by getFieldname(), and setFieldname().

◆ $link

string arWhere::$link = 'AND'
protected

Definition at line 36 of file class.arWhere.php.

Referenced by getLink(), and setLink().

◆ $operator='='

string arWhere::$operator='='
protected

Definition at line 34 of file class.arWhere.php.

◆ $statement

string arWhere::$statement = ''
protected

Definition at line 35 of file class.arWhere.php.

Referenced by getStatement(), and setStatement().

◆ $type

int arWhere::$type = self::TYPE_REGULAR
protected

Definition at line 28 of file class.arWhere.php.

Referenced by getType(), and setType().

◆ $value

arWhere::$value
protected

Definition at line 33 of file class.arWhere.php.

Referenced by asSQLStatement(), getValue(), and setValue().

◆ TYPE_REGULAR

const arWhere::TYPE_REGULAR = 2

Definition at line 27 of file class.arWhere.php.

◆ TYPE_STRING

const arWhere::TYPE_STRING = 1

Definition at line 26 of file class.arWhere.php.

Referenced by ActiveRecordList\where().


The documentation for this class was generated from the following file: