getPrimaryKey()) { $this->_deleteUserDocuments(); } return parent::_deleteDependency(); } protected function _deleteUserDocuments() { $select = $this->_db->select(); $select->from($this->_getPair('ApplicationDocument'), array('id', 'file')); $select->where('`documentTypeId` = ?', $this->getPrimaryKey(), Qs_Db::INT_TYPE); $stmt = $this->_db->query($select); if ($stmt->rowCount() > 0) { $adapter = new Qs_File_Transfer_Adapter_Db(); $adapter->setDefaultDestination(App_Application_Document_AdminObj::DOCUMENT_PATH); $table = new Qs_Db_Table(array('name' => Qs_Db::getTableName('ApplicationDocument'))); while ($row = $stmt->fetch()) { $adapter->delete($row['file']); $table->delete($this->_db->quoteInto('`id` = ?', $row['id'], Qs_Db::INT_TYPE)); } } return $this; } }