Pregunta

->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?

¿Fue útil?

Solución

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.

Otros consejos

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 . '%'))
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top