where('`' . $this->_tableAlias . '`.`parentId` = ?', (int) $this->getPrimaryKey()); return $select; } public function isAllowDelete() { $select = $this->_db->select(); $select->from($this->_getPair(), array('COUNT(Product.id) + COUNT(ParentCategory.id)')); $select->where('`' . $this->_tableAlias . '`.`id` = ?', $this->getPrimaryKey(), Qs_Db::INT_TYPE); $select->group($this->_tableAlias . '.id'); $select->joinLeft( array('ParentCategory' => $this->_getTableName($this->_tableAlias)), '`ParentCategory`.`parentId`=`' . $this->_tableAlias . '`.`id`', array() ); $select->joinLeft( $this->_getPair('Product2Category'), '`Product2Category`.`categoryId` = `' . $this->_tableAlias . '`.`id`', array() ); $select->joinLeft( $this->_getPair('Product'), '`Product`.`id` = `Product2Category`.`productId`', array() ); return !(bool) $this->_db->fetchOne($select); } }