Thanks, I didn’t use CakePhps collections at all until now.
Isn’t that the same as the plain old: $book_ids = array_map(function ($book) { return $book->id; }, $author->books);
?
Back then, when I started with cake 2, I discovered Hash:combine and used it.
Until I noticed how absolutely inperformant it was compared to a simple for loop, that did the same.
So now I’m a bit skeptical about fancy code snippets that already exist in simple php.
Although I admit, with Collections the code is better to read.
Looks like that should do about the same, yes. I like collections, because they are very powerful and chainable, and I find it’s generally best for me to have my code consistent rather than fine-tune for performance in different situations.