Welcome Guest, Not a member yet? Register   Sign In
Query result as an indexed array or object by index of choice
#4

(This post was last modified: 11-16-2020, 02:17 PM by rmilecki.)

(11-16-2020, 11:16 AM)paulbalandan Wrote: There is already a findColumn method which uses array_column for single result. Maybe we can have an analogous findAllColumn() which will do the indexing for set of results.

Perhaps you can send in a PR in the Github repo?
findColumn() uses find() without any argument which means it finds and returns all matching rows. Not just a single row (result).
It uses array_column() without 3rd argument so it doesn't handle any array indexing.

I think it would be inconsistent to have:
  1. findColumn() returning unindexed array (indexed from 0 to n)
  2. findAllColumn() returning indexed array

(11-16-2020, 11:16 AM)paulbalandan Wrote: Perhaps you can send in a PR in the Github repo?
I did, let's see how it goes:
#3895 Model: support returning array indexed by a specified column
Reply


Messages In This Thread
RE: Query result as an indexed array or object by index of choice - by rmilecki - 11-16-2020, 01:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB