Tags
Recent Comments
Elsewhere
Read: "I think saying no is far too often misunderstood and misrepresented. I think it automatically puts..." http://t.co/CTbzPLqX
Bookmarked 19 links
CurdBee - Online billing for small businesses and freelancers.
CurdBee - Online billing for small businesses and freelancers.
UNISON™ - fully-unified communications software
Snipshot: Edit pictures online
Visual and Audio PHP CAPTCHA Generation Class - Ed Eliot
Proto.Menu :: prototype based context menu
Proto.Menu :: prototype based context menu
Website Marketing SEO Score Tool
Sync & Backup Files to the Cloud - Access Online with Any Device ...
Snipshot: Edit pictures online
Visual and Audio PHP CAPTCHA Generation Class - Ed Eliot
UNISON™ - fully-unified communications software
Read: Top 20 Most-Shared Video Ads This Month http://bit.ly/j2oJbS
Links


!["Empire State of Mind" Jay-Z | Alicia Keys [OFFICIAL VIDEO]](http://i.ytimg.com/vi/0UjsXo9l6I8/default.jpg)




Soft Deletable Behavior and the Model::exists() gotcha
If you ever used the Soft Deletable Behavior, you will realise that
Model::del()always returns aFALSE. This is expected after knowing that the behavior intercepts the delete request by saving the deleted flag and date then returningFALSEso the actual delete don’t happen.So since I can’t rely on the returned value of
Model::del(), this is what I thought will work until one fine day the application returns a failure when the record seems to be soft deleted correctly.// some action of a controller $this->Model->id = (int) $idPassed; $this->Model->del(); if ($this->Model->exists()) { // say success! } else { // say failure! }Alas,
Model::exists()sets callbacks toFALSEin itsfind('count')call. So this means nobeforeFindnorafterFindcallbacks gets executed. This is understandable since Model usesexists()in many places where it needs to reflect true existence. So to get the expected results, we have to set callbacks toTRUEinstead.$this->exists(array('callbacks' => true));