exists() public method

Is this entity already saved?
public exists ( ) : boolean
return boolean
Esempio n. 1
0
 private function cleanUpRecords($newValues)
 {
     if (!$this->parent->exists()) {
         return;
     }
     $newIds = [];
     foreach ($newValues as $nv) {
         if (isset($nv['id']) && $nv['id'] != '') {
             $newIds[] = Entity::getInstance()->getDatabase()->id($nv['id']);
         }
     }
     $attrValues = $this->getValue();
     foreach ($attrValues as $r) {
         if (!in_array($r->id, $newIds)) {
             $r->delete();
         }
     }
 }
Esempio n. 2
0
 private function cleanUpRecords($newValues)
 {
     if (!$this->parent->exists()) {
         return;
     }
     $newIds = [];
     foreach ($newValues as $nv) {
         if (isset($nv['id']) && $nv['id'] != '') {
             $newIds[] = Entity::getInstance()->getDatabase()->id($nv['id']);
         }
     }
     $where = ['_id' => ['$nin' => $newIds]];
     $where[$this->relatedAttribute] = $this->parent->id;
     $toRemove = call_user_func_array([$this->entityClass, 'find'], [$where]);
     foreach ($toRemove as $r) {
         $r->delete();
     }
 }