문제

->where("((Job.TwCountry = ? AND Job.TwAbroad = 1) OR (Job.TwCountry != ? AND Job.TwCountryTarget LIKE \"%?%\"))", array($site,$site,$site))

is part of a Propel 1.7 query. As you can see, the three parameters are the same. This does not work, here is the error:

Invalid parameter number: number of bound variables does not match number of tokens

As far as I can tell, the intermediary Propel representation uses the same array keys for all three parameters, thereby losing the fact that they should map to three different PDO parameters. Is there a way round this?

도움이 되었습니까?

해결책

Here is my guess:

->where(
    "((Job.TwCountry = ? AND Job.TwAbroad = 1) OR (Job.TwCountry != ? AND Job.TwCountryTarget LIKE %?%))",
    array($site,$site,$site)
)

The difference is that this Propel method is type-aware, and so will quote your LIKE parameter automatically.

다른 팁

Move your wildcard characters from the query, and placed it on the parameter instead:

->where("((Job.TwCountry = ? AND Job.TwAbroad = 1) OR (Job.TwCountry != ? AND Job.TwCountryTarget LIKE ?))", array($site,$site,'%' . $site . '%'))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top