Where In or clause for when a variable might not exist
What you need to do is take that logic out of the SQL query, and instead use the query builder so to create your query; then you can add the IN statement conditionally, e.g.

// Set up your query
$query = db_select('actions')-&gt;fields('actions');

// See if you have data
if (!empty($types)) {
  // IN is the default operator for arrays so there's no need to specify,
  // but for the sake of an example...
  $query-&gt;condition('type', $types, 'IN');
}

// Get the results
$results = $query-&gt;execute()-&gt;fetchAll();