Example #1
0
 public function delete()
 {
     if (isset($this->_token)) {
         $id = sha1('delete' . $this->_token);
         if (Arrays::is($this->values)) {
             if (Arrays::exists($id, $this->values)) {
                 return call_user_func_array($this->values[$id], func_get_args());
             }
         }
     }
     if (isset($this->db_instance)) {
         return $this->db_instance->delete($this);
     }
     if (isset($this->thin_litedb)) {
         return $this->thin_litedb->delete($this);
     }
     if (isset($this->thin_type)) {
         $type = $this->thin_type;
         Data::getModel($type);
         if (Arrays::exists($type, Data::$_fields)) {
             if (isset($this->id)) {
                 $del = Data::delete($type, $this->id);
             }
         }
         $object = new self();
         $object->setThinType($type);
     } elseif (Arrays::exists('delete', $this->_closures)) {
         $this->_closures['delete']($this);
     } else {
         $object = new self();
     }
     return $object;
 }