Esempio n. 1
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. 2
0
 /**
  * @param ActiveRecord $ar
  *
  * @return string
  */
 public function asSQLStatement(ActiveRecord $ar)
 {
     $return = ' ' . $this->getType() . ' ';
     $return .= ' JOIN ' . $this->getTableName() . ' AS ' . $this->getTableNameAs();
     if ($this->getBothExternal()) {
         $return .= ' ON ' . $this->getOnFirstField() . ' ' . $this->getOperator() . ' ';
     } else {
         $return .= ' ON ' . $ar->getConnectorContainerName() . '.' . $this->getOnFirstField() . ' ' . $this->getOperator() . ' ';
     }
     $return .= $this->getTableNameAs() . '.' . $this->getOnSecondField();
     return $return;
 }
Esempio n. 3
0
 /**
  * @param ActiveRecord $ar
  */
 public function delete(ActiveRecord $ar)
 {
     $ilDB = $this->returnDB();
     $ilDB->manipulate('DELETE FROM ' . $ar->getConnectorContainerName() . ' WHERE ' . arFieldCache::getPrimaryFieldName($ar) . ' = ' . $ilDB->quote($ar->getPrimaryFieldValue(), arFieldCache::getPrimaryFieldType($ar)));
 }
Esempio n. 4
0
 /**
  * @param ActiveRecord $ar
  * @param              $on_this
  * @param              $on_external
  * @param array        $fields
  * @param string       $operator
  *
  * @return $this
  */
 public static function innerjoinAR(ActiveRecord $ar, $on_this, $on_external, $fields = array('*'), $operator = '=', $both_external = false)
 {
     return self::innerjoin($ar->getConnectorContainerName(), $on_this, $on_external, $fields, $operator, $both_external);
 }