Fetch multiple entries from a data source


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.


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.



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.


  {"id" : 0, "name" : "Julia", "age" : "30"},
  {"id" : 1, "name" : "Alexander", "age" : 57}, 
  {"id" : 2, "name" : "Julia", "age" : "71"}, 
  {"id" : 3, "name" : "Selma", "age" : "42"}
  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
  "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.