开发者

Can't get result set, when i use 2 where statements in DQL

开发者 https://www.devze.com 2023-02-09 14:20 出处:网络
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 position

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消