Tags
Recent Comments
Elsewhere
Lousy day n now I am stuck in the car where I can't reverse and the car in front is freaking near.
Original French toast? (@@ octa hotel cafe @@ parco millenia walk) http://4sq.com/aigDMr
No work! Resisting the urge to check my mails. ~~~ (@@ Aerin's @@ Raffles City) http://4sq.com/aGpTYp
Still the best ra-men IMO (@@ Marutama Ramen @@ Liang Court w/ @berilyn) http://4sq.com/58Yssg
Read: LINK: Managing Conflict http://bit.ly/aVrjIG
Bookmarked a link: Sync & Backup Files to the Cloud - Access Online with Any Device ...
RT @jerictan: 陳傑瑞 《我不相信》MV 首播網路版 - 《荒島愛》 電影主題曲 http://fb.me/z5Vo4y8L
I'm at Coffee Club (Holland Village, 48A Lorong Mambong, Singapore). http://4sq.com/8NF3Am
OK girls, it's actually a contest but first 50 entries get S$80 cash! :p I will vote for you! http://bit.ly/c3q8LQ @evonnz @Yee_Ann @Rejinaa
Anyone keen on Free hair colour, treatment and styling?
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));