PDO - how to use: '2078','2080' as a bound parameter

I’m having 2 problems with this PDO code:


$sql = "UPDATE
			`user_listing`
	SET
		`listing_calllist` = 1
	WHERE
		user_id = :user_id AND company_id IN(:company_ids)";
					
		$stmt = $database->conn->prepare($sql);
		
		$stmt->execute(array('user_id' => $_SESSION['user_id'], 'company_ids' => $cids_string));
		

If $cids_string = ‘2078’,‘2082’ neither record updates.

If $cids_string = 2078,2082 then only 2078 updates.

Now if I run this query in phpmyadmin with this WHERE clause: WHERE user_id = 1 AND company_id IN(‘2078’,‘2082’) everything updates as expected.

How can I change this code so PDO likes my comma separated string?

Thanks for looking.



$bind = array('user_id' => $_SESSION['user_id']);
$placeholders = array();

foreach($cids_string as $index=>$value) {
  $bind['company_id_'.$index] = $value;
  $placeholders[] = ':company_id_'.$index;
}

$sql = "UPDATE
			`user_listing`
	SET
		`listing_calllist` = 1
	WHERE
		user_id = :user_id AND company_id IN(".implode(',',$placeholders).")";
 
		$stmt = $database->conn->prepare($sql);
 
		$stmt->execute($bind);

Each item needs to be associated with a separate placeholder and bind variable.

This is one of those areas where it is nice to have an additional layer of database abstraction to handle this easier and without logic repetition everywhere.