Sunday, July 27, 2014

Re: Behavior method won't work

Hmmm, that doesn't work out for me. It seems that it tries to execute a query:

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'referer' at line 1
SQL Query: referer

This is my current AppModel:

class AppModel extends Model {
    
    // soft delete functionaliteit
    
    public function beforeDelete()
    {
        if ($this->hasField('deleted')) {
            if ($this->saveField('deleted', date('Y-m-d H:i:s'))) {
                return $this->redirect($this->referer());
            }
        }
    }
}

I guess $this->redirect() should always been done in a controller? Or is there a way to catch it in the model? 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: