I.m using ORM Doctrine 1.2, and i get this error message:
Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters'
And the method where the DQL is written:
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")
开发者_C百科 ->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;
}
I'm sure that '$searchOptionType,$searchValue,$dateFrom,$dateTill' are correct set.
Please give me something to work with, so is can solve this problem.
Fer.
Try this; it should avoid mixing the two parameter types:
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;
}
精彩评论