title: Call to a member function num_rows() on array in codeigniter query
body: <pre><code>$this-&gt;db-&gt;select("sub_courses as courses");
  $this-&gt;db-&gt;from("second_sub_courses");
  if(!empty($params['searchTerm']))
  {
      $this-&gt;db-&gt;like('courses', $params['searchTerm']);
  }
  $query1 = $this-&gt;db-&gt;get_compiled_select();
  $this-&gt;db-&gt;select("course_name as courses");
  $this-&gt;db-&gt;distinct();
  $this-&gt;db-&gt;from("all_courses");
  if(!empty($params['searchTerm']))
  {
      $this-&gt;db-&gt;like('courses', $params['searchTerm']);
  }
  $query2 = $this-&gt;db-&gt;get_compiled_select(); 
  $query = $this-&gt;db-&gt;query($query1." UNION ".$query2)-&gt;result();
  $result = ($query-&gt;num_rows() &gt; 0)?$query-&gt;result_array():FALSE;
  return $result;
  </code></pre>
  
  <p>I am creating an autocomplete box which not working yet due to this query. Here, I am using a union to get two table data in a single column using <code>courses</code> key attribute but now it throws an error as I mentioned in my question I don't have any idea about this error. How can I fix this error? Please help me.</p>
  
  <p>Thank You</p>