Doctrine Can';当我在DQL中使用2个where语句时,无法获取结果集

Doctrine Can';当我在DQL中使用2个where语句时,无法获取结果集,doctrine,Doctrine,我正在使用ORM条令1.2,我收到以下错误消息: 未捕获异常“Doctrine\u Connection\u Mysql\u exception”,消息为“SQLSTATE[HY093]:无效参数编号:混合命名参数和位置参数” 以及写入DQL的方法: public function SearchComboBothDates($searchOptionType,$searchValue,$dateFrom,$dateTill) { $result = $this->createQ

我正在使用ORM条令1.2,我收到以下错误消息:

未捕获异常“Doctrine\u Connection\u Mysql\u exception”,消息为“SQLSTATE[HY093]:无效参数编号:混合命名参数和位置参数”

以及写入DQL的方法:

public function SearchComboBothDates($searchOptionType,$searchValue,$dateFrom,$dateTill)
{
     $result =  $this->createQuery()
                    ->from("Orders o")
                    ->innerJoin("o.Contractants c")
                    ->innerJoin("c.Persons p")
                    ->innerJoin("p.Addresses a")
                    ->innerJoin("o.Resellers r")
                    ->innerJoin("r.Companies cp")
                    ->innerJoin("o.Cars ca")
                    ->innerJoin("ca.CarTypeScopes cts")
                    ->innerJoin("cts.CarTypes ct")
                    ->innerJoin("ct.CarBrands cb")
                    ->innerJoin("o.Users u")
                    ->innerJoin("o.OrderTypes ot")                      
                    ->where("o.".$searchOptionType." LIKE :searchvalue", array(':searchvalue' => "%".$searchValue."%"))
                    ->andWhere("o.order_date BETWEEN ? AND ? ", array($dateFrom, $dateTill))
                    ->execute();    
    return $result;
}
我确信“$searchOptionType、$searchValue、$dateFrom、$dateTill”的设置是正确的

请给我一些可以解决这个问题的东西


费尔。

试试这个;应避免混合使用两种参数类型:

public function SearchComboBothDates($searchOptionType,$searchValue,$dateFrom,$dateTill)
{
     $result =  $this->createQuery()
                    ->from("Orders o")
                    ->innerJoin("o.Contractants c")
                    ->innerJoin("c.Persons p")
                    ->innerJoin("p.Addresses a")
                    ->innerJoin("o.Resellers r")
                    ->innerJoin("r.Companies cp")
                    ->innerJoin("o.Cars ca")
                    ->innerJoin("ca.CarTypeScopes cts")
                    ->innerJoin("cts.CarTypes ct")
                    ->innerJoin("ct.CarBrands cb")
                    ->innerJoin("o.Users u")
                    ->innerJoin("o.OrderTypes ot")                      
                    ->where("o.".$searchOptionType." LIKE ?", "%".$searchValue."%")
                    ->andWhere("o.order_date BETWEEN ? AND ? ", array($dateFrom, $dateTill))
                    ->execute();    
    return $result;
}