/** * * @param Datastore $oDB * the datastore to search for the record * @param array $aConditions * The criteria to use to search for the record */ public function findByKey($oDB, $aConditions) { constraint_mustBeArray($aConditions); $oAdapter = $oDB->getAdapterFor($this); $return = $oAdapter->findByKey($this, $aConditions); if (!$return) { // we did not find the record // // if the record is expected to exist, we throw // an exception $oDef = $this->oModel->getDefinition(); $mustExist = false; foreach ($aConditions as $field => $value) { if ($oDef->isValidFieldName($field) && $oDef->isMandatoryField($field)) { $mustExist = true; } } if ($mustExist) { throw new Datastore_E_RelatedDataNotFound($oDef->getModelName(), $aConditions); } else { return false; } } return true; }