CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

feat: add `array_duplicate_by()` helper to get duplicate array by column

Open ddevsr opened this issue 1 year ago • 6 comments

Description Add array_duplicate_by function to get duplicate array by column.

Checklist:

  • [x] Securely signed commits
  • [x] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [x] Unit testing, with >80% coverage
  • [ ] User guide updated
  • [x] Conforms to style guide

ddevsr avatar Jan 20 '24 13:01 ddevsr

I wonder about the overall usefulness of this helper method... I'm not entirely convinced, but if others see potential in it, I won't be opposed.

michalsn avatar Jan 20 '24 19:01 michalsn

I wonder too. Can you show use cases?

kenjis avatar Jan 20 '24 22:01 kenjis

@michalsn @kenjis I have real cases in my project

Used for upload batch by excel, I made this so that when uploading hospital or member master data it immediately rejects duplication without needing to check it from the database. As we all know, to save to the database, doing it by looping and checking in it will take a lot of time.

This result can be show to alert, when creating like 6000 data you dont check by excel again

ddevsr avatar Jan 21 '24 00:01 ddevsr

@ddevsr I do not doubt that you have a use case for this, but I'm not sure if this is such a common problem to add it to the framework.

michalsn avatar Jan 21 '24 18:01 michalsn

@kenjis @michalsn I follow decision core team

ddevsr avatar Jan 22 '24 08:01 ddevsr

I posted in the forum. https://forum.codeigniter.com/showthread.php?tid=89308

kenjis avatar Feb 04 '24 01:02 kenjis

There are more people who disagree.

We would encourage people to use libraries over adding functions to the framework core - especially Helpers since they aren’t easily extensible, replaceable, or portable.

kenjis avatar Mar 05 '24 22:03 kenjis