1

I'm trying to make a compound statement where it will select threads where the 'node_id' column is in an array of values set in $node_ids

$node_ids = ['13', '14'];
$db = $this->app->db();
return $db->fetchAllColumn($db->limit("
        SELECT thread_id
        FROM xf_thread
        WHERE thread_id > ?
        AND node_id in " . $node_ids . "
        ORDER BY thread_id
    ", $batch
), $start);

However I get an error

Array to string conversion

on the line with:

AND node_id in " . $node_ids . "
user3783243
  • 5,368
  • 5
  • 22
  • 41

1 Answers1

0

This works based on comment by Barmar:

$node_ids = ['13', '14'];
$db = $this->app->db();
return $db->fetchAllColumn($db->limit("
        SELECT thread_id
        FROM xf_thread
        WHERE thread_id > ?
        AND node_id in (" . implode(',', $node_ids) . ")
        ORDER BY thread_id
    ", $batch
), $start);