I need to write a query with a IN
condition and multiple WHERE
condition. I have tried following SQL statement but this one is not getting me result. Maybe I did something wrong.
SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters
$columns = "DISTINCT model, manufacturer, logo, year, update_status";
$modelList = array('Version', 'Facelift', 'Optionsänderung');
$orderBy = "manufacturer, model";
// Prepare the sql statement.
$sql = "select $columns from tbl_manufacture where model IN (:modelList) year > ? AND update_status = ?";
$sql.="order by $orderBy";
$em = $this->getEntityManager();
$query = $em->getConnection()
->prepare($sql);
$query->bindValue("modelList", $modelList, Connection::PARAM_STR_ARRAY);
$params = array(
"year" => $year,
"update_status" => $status
);
// Execute the statement
$query->execute($params);