I'm trying to bind an array of strings into the where-in condition. I used the parameters conversions constants also. But it seems to be not working.
Following one is my query.
$buQuery = "SELECT bu.ID, bu.BUSINESS_NAME FROM business as bu WHERE bu.ID IN (:business)";
$buStmt = self::getConnection($this->entityManager)->prepare($buQuery);
$buStmt->bindValue("business", $business, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
$buStmt->execute();
$responseData = $buStmt->fetch();
return $responseData;
and the array I'm passing for the in condition is (I have printed this array from the parameters list and copied it over here.)
$business = Array ( 0 => 'mobile', 1 => 'iot' );
The error the doctrine throws me is:
An Exception was thrown while handling: An exception occurred while executing SELECT bu.ID, bu.BUSINESS_NAME FROM business as bu WHERE bu.ID IN (:business) with params "[["mobile","iot"]]:"
Notice: Array to string conversion
I have noticed the array is not getting converted properly. I have referred the following links, but nothing helped me.
Stackoverflowlink1 Stackoverflowlink2 Doctrinelink1
Note: I have used the "PARAM_INT_ARRAY" also. And also I tried "array_values" while passing the array as parameter in the bind statement.