Esempio n. 1
0
 /**
  * @return bool
  */
 protected function generateFields()
 {
     $fields = $this->active_record->getArFieldList()->getFields();
     foreach ($fields as $standard_field) {
         $current_class = get_called_class();
         $field_class = $current_class::FIELD_CLASS;
         /**
          * @var arViewField $field_class
          */
         $field = $field_class::castFromFieldToViewField($standard_field);
         $this->addField($field);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * @description Build WHERE Statement
  *
  * @param ActiveRecord $ar
  *
  * @throws arException
  * @return string
  */
 public function asSQLStatement(ActiveRecord $ar)
 {
     if ($this->getType() == self::TYPE_REGULAR) {
         $arField = $ar->getArFieldList()->getFieldByName($this->getFieldname());
         if ($arField instanceof arField) {
             $type = $arField->getFieldType();
             $statement = $ar->getConnectorContainerName() . '.' . $this->getFieldname();
         } else {
             $statement = $this->getFieldname();
         }
         if (is_array($this->getValue())) {
             if (in_array($this->getOperator(), array('IN', 'NOT IN', 'NOTIN'))) {
                 $statement .= ' ' . $this->getOperator() . ' (';
             } else {
                 $statement .= ' IN (';
             }
             $values = array();
             foreach ($this->getValue() as $value) {
                 $values[] = $ar->getArConnector()->quote($value, $type);
             }
             $statement .= implode(', ', $values);
             $statement .= ')';
         } else {
             if ($this->getValue() === NULL) {
                 $this->setOperator('IS');
             }
             $statement .= ' ' . $this->getOperator();
             $statement .= ' ' . $ar->getArConnector()->quote($this->getValue(), $type);
         }
         $this->setStatement($statement);
     }
     return $this->getStatement();
 }
Esempio n. 3
0
 /**
  * @param ActiveRecord $ar
  *
  * @return bool
  */
 public function updateDatabase(ActiveRecord $ar)
 {
     $ilDB = $this->returnDB();
     foreach ($ar->getArFieldList()->getFields() as $field) {
         if (!$ilDB->tableColumnExists($ar->getConnectorContainerName(), $field->getName())) {
             $ilDB->addTableColumn($ar->getConnectorContainerName(), $field->getName(), $field->getAttributesForConnector());
         }
     }
     return true;
 }