Example #1
0
    /**
     * @param \Zend_DB_Select $select
     *
     * @return $this
     */
    protected function addJoins(\Zend_DB_Select $select)
    {
        // add fielcollection's
        $fieldCollections = $this->model->getFieldCollections();
        if (!empty($fieldCollections)) {
            foreach ($fieldCollections as $fc) {
                // join info
                $table = 'object_collection_' . $fc['type'] . '_' . $this->model->getClassId();
                $name = $fc['type'];
                if (!empty($fc['fieldname'])) {
                    $name .= "~" . $fc['fieldname'];
                }
                // set join condition
                $condition = <<<CONDITION
1
 AND {$this->db->quoteIdentifier($name)}.o_id = {$this->db->quoteIdentifier($this->getTableName())}.o_id
CONDITION;
                if (!empty($fc['fieldname'])) {
                    $condition .= <<<CONDITION
 AND {$this->db->quoteIdentifier($name)}.fieldname = "{$fc['fieldname']}"
CONDITION;
                }
                // add join
                $select->joinLeft([$name => $table], $condition, '');
            }
        }
        // add brick's
        $objectbricks = $this->model->getObjectbricks();
        if (!empty($objectbricks)) {
            foreach ($objectbricks as $ob) {
                // join info
                $table = 'object_brick_query_' . $ob . '_' . $this->model->getClassId();
                $name = $ob;
                // add join
                $select->joinLeft([$name => $table], <<<CONDITION
1
AND {$this->db->quoteIdentifier($name)}.o_id = {$this->db->quoteIdentifier($this->getTableName())}.o_id
CONDITION
, '');
            }
        }
        return $this;
    }
 /**
  * @param \Zend_DB_Select $select
  *
  * @return $this
  */
 protected function addConditions(\Zend_DB_Select $select)
 {
     $condition = $this->model->getCondition();
     if ($condition) {
         $select->where($condition);
     }
     return $this;
 }
Example #3
0
File: Dao.php Project: sfie/pimcore
 /**
  * @param \Zend_DB_Select $select
  *
  * @return $this
  */
 protected function addConditions(\Zend_DB_Select $select)
 {
     $condition = $this->model->getCondition();
     $objectTypes = $this->model->getObjectTypes();
     if (!empty($objectTypes)) {
         if (!empty($condition)) {
             $condition .= " AND ";
         }
         $condition .= " o_type IN ('" . implode("','", $objectTypes) . "')";
     }
     if ($condition) {
         if (Object\AbstractObject::doHideUnpublished() && !$this->model->getUnpublished()) {
             $condition = "(" . $condition . ") AND o_published = 1";
         }
     } else {
         if (Object\AbstractObject::doHideUnpublished() && !$this->model->getUnpublished()) {
             $condition = "o_published = 1";
         }
     }
     if ($condition) {
         $select->where($condition);
     }
     return $this;
 }
Example #4
0
 /**
  * @param \Zend_DB_Select $select
  *
  * @return $this
  */
 protected function addConditions(\Zend_DB_Select $select)
 {
     $condition = $this->model->getCondition();
     $objectTypes = $this->model->getObjectTypes();
     $tableName = method_exists($this, "getTableName") ? $this->getTableName() : "objects";
     if (!empty($objectTypes)) {
         if (!empty($condition)) {
             $condition .= " AND ";
         }
         $condition .= " " . $tableName . ".o_type IN ('" . implode("','", $objectTypes) . "')";
     }
     if ($condition) {
         if (Object\AbstractObject::doHideUnpublished() && !$this->model->getUnpublished()) {
             $condition = "(" . $condition . ") AND " . $tableName . ".o_published = 1";
         }
     } elseif (Object\AbstractObject::doHideUnpublished() && !$this->model->getUnpublished()) {
         $condition = $tableName . ".o_published = 1";
     }
     if ($condition) {
         $select->where($condition);
     }
     return $this;
 }