示例#1
0
 /**
  * Delete all objects in one class BUT NOT in its subclasses 
  * object relationships
  * @param epClassMap $cm
  * @return bool
  * @access protected
  */
 protected function _deleteAll(epClassMap $cm)
 {
     // get class name
     $class = $cm->getName();
     // check if class has any non-primitive fields
     if (!$cm->hasNonPrimitive()) {
         // if not, simply call parent to delete all
         return parent::deleteAll($class);
     }
     // check if class has any composed_of fields
     if (!($cofs = $cm->getComposedOf())) {
         // call parent to delete all
         $status = parent::deleteAll($class);
         // remove relations from and to the class
         $status &= $this->_deleteRelations($class);
         return $status;
     }
     // otherwise, we need to go through each object and delete the composed_of fields
     // this is an expensive operation. should be optimized.
     // get all objects of the class
     if (!($os = $this->getAll($class))) {
         return true;
     }
     // delete every object
     $status = true;
     foreach ($os as $o) {
         $status &= $this->delete($o);
     }
     return $status;
 }