_db->select() ->from(array('rb' => $this->_getTableName()), array('title', 'content', 'colorClass', 'sorter')) ->join(array('pg' => $this->_getTableName("{$this->_tableAlias}2Page")), '`pg`.`idRightBlock` = `rb`.`id`', '') ->where('`pg`.`idPage` = ' . $this->_idPage) ->where('`rb`.`typePage` <> "all"'); $allPagesBlock = $this->_db->select() ->from(array('rb' => $this->_getTableName()), array('title', 'content', 'colorClass', 'sorter')) ->where('`rb`.`typePage` = "all"'); $this->select->reset()->union(array($customPagesBlock, $allPagesBlock)); $this->_prepareListOptions($options); return $this->select; } public function setIdPage($id) { $this->_idPage = $id; return $this; } }