original_string: final public function delete() {
          global $DB;
  
          if ($this->raw_get('id') <= 0) {
              throw new coding_exception('id is required to delete');
          }
  
          // Hook before delete.
          $this->before_delete();
  
          $result = $DB->delete_records(static::TABLE, array('id' => $this->raw_get('id')));
  
          // Hook after delete.
          $this->after_delete($result);
  
          // Reset the ID to avoid any confusion, this also invalidates the model's data.
          if ($result) {
              $this->raw_set('id', 0);
          }
  
          return $result;
      }
code: final public function delete() {
          global $DB;
  
          if ($this->raw_get('id') <= 0) {
              throw new coding_exception('id is required to delete');
          }
  
          // Hook before delete.
          $this->before_delete();
  
          $result = $DB->delete_records(static::TABLE, array('id' => $this->raw_get('id')));
  
          // Hook after delete.
          $this->after_delete($result);
  
          // Reset the ID to avoid any confusion, this also invalidates the model's data.
          if ($result) {
              $this->raw_set('id', 0);
          }
  
          return $result;
      }
code_tokens: final public function delete ( ) { global $ DB ; if ( $ this -> raw_get ( 'id' ) <= 0 ) { throw new coding_exception ( 'id is required to delete' ) ; } // Hook before delete. $ this -> before_delete ( ) ; $ result = $ DB -> delete_records ( static :: TABLE , array ( 'id' => $ this -> raw_get ( 'id' ) ) ) ; // Hook after delete. $ this -> after_delete ( $ result ) ; // Reset the ID to avoid any confusion, this also invalidates the model's data. if ( $ result ) { $ this -> raw_set ( 'id' , 0 ) ; } return $ result ; }
docstring: Delete an entry from the database.
  
  @return bool True on success.
docstring_tokens: Delete an entry from the database .