datasource_many

Modified on Thu, 9 Jul at 10:50 AM

datasource_many

TABLE OF CONTENTS

Fetch multiple entries from a data source

Definition

object datasource_many(string $dataSourceName, string $column, string $lookFor)

Gets the array of all objects from $dataSourceName whose value of $column is equal to $lookFor.

Parameters

string $dataSourceName

Name of the data source to use.

string $column

Name of the column to search.

string $lookFor

The string value to look for in $column. $lookFor needs to be a string regardless of the data type in the datasource.

Returns

object

The array of all objects in $dataSourceName whose value of $column in equal to $lookFor. If there are missing values in $column, throws exception. Empty array if no matches.

Examples

ExampleDatasource
[
  {"id" : 0, "name" : "Julia", "age" : "30"},
  {"id" : 1, "name" : "Alexander", "age" : 57}, 
  {"id" : 2, "name" : "Julia", "age" : "71"}, 
  {"id" : 3, "name" : "Selma", "age" : "42"}
]
Transformation
{
  julias: datasource_many('ExampleDatasource', 'name', 'Julia'),
  alexanderAge: datasource_many('ExampleDatasource', 'name', 'Alexander')[].age,
  alex: datasource_many('ExampleDatasource', 'name', 'Alex'),
  namesOf30YearOlds: datasource_many('ExampleDatasource', 'age', '30')[].name
}
Result
{
  "julias": [{"id": 0, "name": "Julia", "age": "30"},
             {"id": 2, "name": "Julia", "age": "71"}],
  "alexanderAge": [57],
  "alex": [],
  "namesOf30YearOlds": ["Julia"]
}

See also

  • datasource, a similar function that returns only the first object that matches a certain value.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article