_getMemberAmountSubselect() . ')'); return $columns; } protected function _getMemberAmountSubselect() { $select = $this->_db->select(); $select->from($this->_getPair('User'), 'COUNT(*)'); $select->where('`' . $this->_tableAlias . '`.`id` = `User`.`groupId`'); return $select; } protected function _getFromDbColumns() { $columns = parent::_getFromDbColumns(); $columns['amount'] = new Zend_Db_Expr('(' . $this->_getMemberAmountSubselect() . ')'); return $columns; } public function delete() { if ($this->getData('amount') > 0) { $this->_addError('Group \'' . $this->getData('title') . '\' is not empty and can\'t be removed.'); return false; } return parent::delete(); } }