ResultSet - magroski/frogg GitHub Wiki
ResultSet
This class is used to replace Phalcon default ResultSet
interface when querying data with ::find()
Below are some usage examples for each function:
getAttribute(string $attributeName)
$users = User::find($params);
$user->getAttribute('name');
> ['Carl', 'Ana', 'James', ...];
getAttributes(...$attributeNames)
$users = User::find();
$user->getAttributes('name', 'age'); //The amount of parameters is variable
> [ ['name' => 'Peter', 'age' => 20], ['name' => 'Hilda', 'age' => 22] ]
groupBy(string $attributeName, $asObject = true)
$users = User::find();
$user->groupBy('name');
> [ 'Peter' => [object1, object2, ...], 'Anne' => [object3], ...];
If $asObject
is passed as false
, it will return each entry as an array instead of an instance of the object.
toObjectArray()
$users = User::find();
$user->toObjectArray();
> [ object1, object2, object3, ...];
isEmpty()
$users = User::find();
$user->isEmpty();
> false
isNotEmpty()
$users = User::find();
$user->isNotEmpty();
> true
getIds()
Is an alias for getAttribute('id')