experimenting with refactoring some old code and figured I would experiment with apiv4. the first hurdle was figuring out how to use the ArrayObject that is returned.
in apiv3, for example I would look at the count value in the array. in apiv4 there is no such value.
my api v3 call looks like this
$result = civicrm_api3('Contact', 'get', array(
'return' => array("custom_90", "custom_91", "custom_85", "custom_88", "custom_143"),
'id' => $alum_cid,
'custom_143' => $sal['id'],
));
if ($result['count'] != 0) {
do things
}
my apiv4 call looks like this
$results = \Civi\Api4\Contact::get()
->setSelect([
'Employment_History.Salary_Yearly_',
'Employment_History.Currency',
'Employment_History.Employer',
'Employment_History.End_Date',
'Employment_History.relationshipID'
])
->addWhere('id', '=', $alum_cid)
->addWhere('Employment_History.relationshipID', '=', $sal['id'])
->setLimit(25)
->execute();
how do I get the count of the results?