Reputation: 6593
->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?
Upvotes: 1
Views: 213
Reputation: 2629
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 . '%'))
Upvotes: 0
Reputation: 20467
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.
Upvotes: 1