# |
Jun 29th 2018, 13:33 |
itmpls |
and by that i mean the 30 club |
# |
Jun 29th 2018, 13:33 |
lorenzo |
nice! |
# |
Jun 29th 2018, 13:31 |
itmpls |
oh man |
# |
Jun 29th 2018, 13:31 |
itmpls |
nice. i'm going to join you soon. 29 now, couple days |
# |
Jun 29th 2018, 13:31 |
itmpls |
ah |
# |
Jun 29th 2018, 13:31 |
lorenzo |
33 |
# |
Jun 29th 2018, 13:30 |
itmpls |
@lorenzo how old are you now |
# |
Jun 29th 2018, 13:20 |
lorenzo |
thanks medes |
# |
Jun 29th 2018, 13:14 |
itmpls |
happy bday @lorenzo |
# |
Jun 29th 2018, 13:09 |
jhob |
just reading up on anonymous functions in PHP docs now! :slightly_smiling_face: |
# |
Jun 29th 2018, 12:58 |
josbeir |
now you are! ;) |
# |
Jun 29th 2018, 12:54 |
jhob |
thanks, wasn't familiar with the use syntax :slightly_smiling_face: |
# |
Jun 29th 2018, 12:49 |
josbeir |
$ladies = $collection->reject(function ($person, $key) use($var) { $var == .. |
# |
Jun 29th 2018, 12:47 |
jhob |
Apologies if this is a really basic question, but how do I pass a var to compare to the filter callback, e.g. (I want to pass $gender) `$collection = new Collection($people); $ladies = $collection->reject(function ($person, $key) { return $person->gender === $gender; });` |
# |
Jun 29th 2018, 12:36 |
jhob |
awesome, thank you! Looking at implementing this now |
# |
Jun 29th 2018, 12:36 |
josbeir |
:point_up: |
# |
Jun 29th 2018, 12:35 |
saeideng |
The inverse of `filter()` is `reject()` |
# |
Jun 29th 2018, 12:35 |
saeideng |
it is easy to use `reject()` here |
# |
Jun 29th 2018, 12:31 |
josbeir |
=>https://book.cakephp.org/3.0/en/core-libraries/collections.html#filtering => https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#modifying-results-with-map-reduce |
# |
Jun 29th 2018, 12:31 |
jhob |
Thanks. Did look at updating users but also nervous about breaking other stuff. Cheers for pointers. |
# |
Jun 29th 2018, 12:31 |
josbeir |
or just toArray() and unset() the key :P |
# |
Jun 29th 2018, 12:30 |
josbeir |
@jhob multiple choices, you can use map/reduce or use a collection method |
# |
Jun 29th 2018, 12:28 |
jhob |
How do I unset/remove a record from a Cake\ORM\ResultSet ? |
# |
Jun 29th 2018, 12:05 |
lorenzo |
thanks @josbeir |
# |
Jun 29th 2018, 12:00 |
josbeir |
:partyparrot: |
# |
Jun 29th 2018, 12:00 |
josbeir |
oh @lorenzo its your bd, happy bday! |
# |
Jun 29th 2018, 11:50 |
bernat |
thanks |
# |
Jun 29th 2018, 11:46 |
josbeir |
nope |
# |
Jun 29th 2018, 11:45 |
bernat |
I guess not. Too specific probably. :s |
# |
Jun 29th 2018, 11:45 |
bernat |
I'm solving it myself already, just asking if there was some hack in the framework or some plugin that solves it automatically. |
# |
Jun 29th 2018, 11:45 |
josbeir |
and check if it has already been converted and just return the converted object(s) |
# |
Jun 29th 2018, 11:44 |
josbeir |
Why not just store it somewhere after converting it? |
# |
Jun 29th 2018, 11:44 |
bernat |
What bothers specially is that when reading Products->Services, the object instances for Services get duplicated instead of being reused. |
# |
Jun 29th 2018, 11:43 |
bernat |
I want to read the association Services->Products just one time from the database. And somewhere in the code I need Services->Products and in other places it would be handy to have Products->Services. I could load Services->Products->Services but that means a lot of reading from the database and lots of duplicated instances. |
# |
Jun 29th 2018, 11:42 |
josbeir |
ok, i was a little too quick in reading your question.. yeah what @tim said or doing it after fetching somewhere |
# |
Jun 29th 2018, 11:41 |
josbeir |
:) |
# |
Jun 29th 2018, 11:41 |
josbeir |
i'm still not getting the question but thats just me |
# |
Jun 29th 2018, 11:40 |
bernat |
Right tim, but when I need this it's because I need the association both ways. |
# |
Jun 29th 2018, 11:40 |
bernat |
It's easy to do it myself but I found myself doing it many times and I thought it might be already solved. |
# |
Jun 29th 2018, 11:39 |
tim |
Why not just load Services instead and contain Products? |
# |
Jun 29th 2018, 11:39 |
bernat |
No, I just mean using arrays/collections. No persistence involved. |