How do I add a condition to a query?
Conditions are only used in dynamic queries; the query() method is for running static SQL.

The dynamic version would be something like:

$result = $database
  -&gt;select('acl_node', 'n')
  -&gt;fields('n', ['nid'])
  -&gt;condition('grant_update', 1)
  -&gt;condition('acl_id', $acl_ids, 'IN')
  -&gt;execute()
  -&gt;fetchField();


And the static:

$result = $database
  -&gt;query("SELECT nid FROM {acl_node} WHERE grant_update = :grant AND acl_id IN (:acl_ids[])", [':grant' =&gt; 1, ':acl_ids[]' =&gt; $acl_ids])
  -&gt;fetchField();