original_string: public function delete($id = null)
      {
          if (!is_null($id)) {
              $this->load($id);
          }
          if (!$this->loaded()) {
              throw $this->exception('Unable to determine which record to delete');
          }
  
          $tmp = $this->dsql;
  
          $this->initQuery();
          $delete = $this->dsql->where($this->id_field, $this->id);
  
          $delete->owner->beginTransaction();
          $this->hook('beforeDelete', array($delete));
          $delete->delete();
          $this->hook('afterDelete');
          $delete->owner->commit();
  
          $this->dsql = $tmp;
          $this->unload();
  
          return $this;
      }
code: public function delete($id = null)
      {
          if (!is_null($id)) {
              $this->load($id);
          }
          if (!$this->loaded()) {
              throw $this->exception('Unable to determine which record to delete');
          }
  
          $tmp = $this->dsql;
  
          $this->initQuery();
          $delete = $this->dsql->where($this->id_field, $this->id);
  
          $delete->owner->beginTransaction();
          $this->hook('beforeDelete', array($delete));
          $delete->delete();
          $this->hook('afterDelete');
          $delete->owner->commit();
  
          $this->dsql = $tmp;
          $this->unload();
  
          return $this;
      }
code_tokens: public function delete ( $ id = null ) { if ( ! is_null ( $ id ) ) { $ this -> load ( $ id ) ; } if ( ! $ this -> loaded ( ) ) { throw $ this -> exception ( 'Unable to determine which record to delete' ) ; } $ tmp = $ this -> dsql ; $ this -> initQuery ( ) ; $ delete = $ this -> dsql -> where ( $ this -> id_field , $ this -> id ) ; $ delete -> owner -> beginTransaction ( ) ; $ this -> hook ( 'beforeDelete' , array ( $ delete ) ) ; $ delete -> delete ( ) ; $ this -> hook ( 'afterDelete' ) ; $ delete -> owner -> commit ( ) ; $ this -> dsql = $ tmp ; $ this -> unload ( ) ; return $ this ; }
docstring: Deletes record matching the ID
docstring_tokens: Deletes record matching the ID