Thanks Joshua, That works just as needed. Dave _____
From: joshua [mailto:josh...@gmail.com] Sent: August-11-09 1:14 AM To: cake-php@googlegroups.com Subject: Re: Array help I think you can define a model level filter, it will help you to solve this problem thoroughly. Just an idea of mine. Maybe you can put the filter engine in AppModel. [Client] ----> {Filter engine} ----> [Server] [Client] <--- {Filter engine} <---- [Server] For a temporary solution, I think the loop is enough: Assume the return result something like this: [0] => Array ( [Bookmark] => Array ( [id] => 38b7276f708 [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b [post_id] => 11e7ee [created] => 2009-08-09 21:59:01 ) [Post] => Array ( [title] => Test Title [rank] => 2 [created] => [description] => Test dscription [id] => 52louj ) ) [1] => Array ( [Bookmark] => Array ( [id] => 38b7276f708 [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b [post_id] => 11e7ee [created] => 2009-08-09 21:59:01 ) [Post] => Array ( [title] => [rank] => [created] => [description] => [id] => ) ) [CODE] foreach ($bookmarks as $key => $value) { if (empty($value['Post']['id'])) { unset($bookmarks[$key]['Post']); } } [/CODE] On Tue, Aug 11, 2009 at 11:19 AM, Dave Maharaj :: WidePixels.com <d...@widepixels.com> wrote: The thing is the Post info is there in the database Scenario: The Post article has access level of 1 User that has an access level of 1 can see the Post and bookmark it. No problem Later the owner of the Post changes the access level to 3....the user with level 1 access can no loger see that Post because his access level is too low, but his Bookmark for that Post still exists. But because the contain will pull all bookmarks that belongto the user andgetthe Posts where $access = 'Post.access' that info is no longer goingto get pulled, thats why it appears blank. So I need to completely remove that bookmark from the array. Trying something like: foreach ($bookmark as $key => $value) { if (empty($value)) { unset($q[$key]); but cant get it to work...still messing around with it _____ From: joshua [mailto:josh...@gmail.com] Sent: August-11-09 12:41 AM To: cake-php@googlegroups.com Subject: Re: Array help 1. Use a callback function afterFind to loop the return array, remove the empty item. 2. How about give a condition when model->find. [CODE] 'conditions' => array(("not" => array ( "Post.id" => null )), //array of conditions [/CODE] On Tue, Aug 11, 2009 at 10:25 AM, Dave Maharaj :: WidePixels.com <d...@widepixels.com> wrote: I have a contain query which produces these results. Basically the user bookmarked a page when they had access. The Owner of the post has changed the level of who can view the Post so in this case this user no longer can view the post hence the missing post data. It was not grabbed because the conditions of the Post did not match the users access level. But the bookmark still exists. Now in the query it pulls all bookmarks for the user and the post related to the bookmark. How can I remove [1] from the array all together or all from the array if [Post] has no data? I can not delete the bookmark when Posts change the access level because they may change it back to a lower setting and allow those who did have it bookmarked to once again have access. I just need to remove the array entry(s) where the Post array is empty. [0] => Array ( [Bookmark] => Array ( [id] => 38b7276f708 [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b [post_id] => 11e7ee [created] => 2009-08-09 21:59:01 ) [Post] => Array ( [title] => Test Title [rank] => 2 [created] => [description] => Test dscription [id] => 52louj ) ) [1] => Array ( [Bookmark] => Array ( [id] => 38b7276f708 [user_id] => 4a5d569f-b9e8-416d-b34c-11cf4adcd75b [post_id] => 11e7ee [created] => 2009-08-09 21:59:01 ) [Post] => Array ( [title] => [rank] => [created] => [description] => [id] => ) ) Thanks, Dave -- Thanks Joshua 5span.com <https://www.5span.com> -- Thanks Joshua 5span.com <https://www.5span.com> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---