Using the fetch() method in database query to get an array
You can use fetchAllKeyed try with:

  $connection = \Drupal::database();
    $query = $connection-&gt;select('node_field_data', 'n');
    $query-&gt;condition('n.type', 'employee');
    $query-&gt;condition('n.status', 1);
    $query-&gt;fields('n', ['nid', 'title']);
    // use fetchAllKeyed
    $results = $query-&gt;execute()-&gt;fetchAllKeyed(0,1);