ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 (mixed $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(), null, 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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 143 of file class.arWhere.php.

References $link.

143  : string
144  {
145  return $this->link;
146  }
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 133 of file class.arWhere.php.

References $statement.

Referenced by asSQLStatement().

133  : string
134  {
135  return $this->statement;
136  }
string $statement
+ Here is the caller graph for this function:

◆ getType()

arWhere::getType ( )

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

References $type.

Referenced by asSQLStatement().

123  : int
124  {
125  return $this->type;
126  }
+ Here is the caller graph for this function:

◆ getValue()

arWhere::getValue ( )
Returns
mixed|null

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

References $value.

Referenced by asSQLStatement().

114  {
115  return $this->value;
116  }
+ 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 138 of file class.arWhere.php.

References $link, and ILIAS\Repository\link().

138  : void
139  {
140  $this->link = $link;
141  }
string $link
link(string $caption, string $href, bool $new_viewport=false)
+ Here is the call graph for this function:

◆ 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 128 of file class.arWhere.php.

References $statement.

Referenced by asSQLStatement().

128  : void
129  {
130  $this->statement = $statement;
131  }
string $statement
+ Here is the caller graph for this function:

◆ setType()

arWhere::setType ( int  $type)

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

References $type.

118  : void
119  {
120  $this->type = $type;
121  }

◆ setValue()

arWhere::setValue ( mixed  $value)

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

References $value.

105  : void
106  {
107  $this->value = $value;
108  }

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: