Easily convert data object to array Help

How do I easily convert this into an array? Can I do toArray?

$employees = TableRegistry::get(‘employees’)->find(‘all’, array(‘fields’=> array(‘EMPLOYEEID’,‘FIRSTNAME’, ‘LASTNAME’)))->toList();

Is this CakePHP 2 or CakePHP 3?

the version of cakephp I am using is version 3.6

try using toArray():

$employees = TableRegistry::get('employees')->find('all', array('fields'=> array('EMPLOYEEID','FIRSTNAME', 'LASTNAME')))->toArray();

You are using the old syntax. Better to change it to

$employees = TableRegistry::get(‘employees’)->find(‘all’)->select(array(‘EMPLOYEEID’,‘FIRSTNAME’, ‘LASTNAME’))->toArray();

1 Like

Awesome Thanks for your willingness to help me out !