Friday, May 1, 2009

Removing an item from a set using Set::Remove.

Suppose I have the following set:

Array
(
[0] => Array
(
[Event] => Array
(
[id] => 1
[name] => 1
)

)

[1] => Array
(
[Event] => Array
(
[id] => 2
[name] => 2
)
)

[2] => Array
(
[Event] => Array
(
[id] => 3
[name] => 3
)

)

)

( This set was generate using $this->Event->find('all'); )

Now suppose I want to remove from this set the "Event" with id "2".
How would I do this? I don't want to remove it from the DB, I just
want to remove it from the set, so it doesn't get displayed in the
view.

I thought I could do this with Set::Remove. However the documentation
here is quite sparse. And doing a search for "Set::Remove" on both the
cakephp sites and this groups didn't turn up a single hit...

Anyway, I tried:
Set::remove($events, '{n}.Event.id' , 2);

But that didn't do anything.

Any pointers to help me in the right direction?

Krist

--
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: