Tags
Recent Comments
Elsewhere
I'm at Seoul Yummy (United Square 2). http://4sq.com/aKZDsC
I'm at kichn w/ @hanyuan @jeffshi @dfcn84. http://4sq.com/8Lh67j
That is a lot to travel. The holiday starts now! (@@ Sapa Global Hotel w/ @calvinchar @hanyuan @berilyn) http://4sq.com/cZmFwY
Skynet. Yummy. (@@ Tan Son Nhat International Airport (SGN) w/ @hanyuan @berilyn) http://4sq.com/doyPjh
Alright!! (@@ D36 @@ Changi Terminal 1 w/ @calvinchar @berilyn) http://4sq.com/cGukhy
Read: The “Magic” Behind Apple’s New Battery http://bit.ly/diMSou
Read: Changes to Boxes and Application Tabs on Facebook Pages will be implemented starting the week of August 23. ... http://bit.ly/alC6wF
The one good thing about taking the train is the travelling time spent working. Hmm..
Bookmarked 2 links
Lousy day n now I am stuck in the car where I can't reverse and the car in front is freaking near.
Links
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));