| От | Tino Wildenhain |
|---|---|
| Тема | Re: Secure "where in(a,b,c)" clause. |
| Дата | |
| Msg-id | 47F635B9.60504@wildenhain.de обсуждение исходный текст |
| Ответ на | Re: Secure "where in(a,b,c)" clause. (Steve Atkins <steve@blighty.com>) |
| Список | pgsql-general |
Steve Atkins wrote:
...
> I count the number of values that I want to put in the IN () clause,
> then create a query string with the right number of bind variables
> in the in clause, then bind the values.
>
> So for {1, 3, 5} I'd use "select * from foo where bar in (?, ?, ?)" and for
> {1,5,7,9,11} I'd use "select * from foo where bar in (?, ?, ?, ?, ?)"
>
> Then, in perl-speak, I prepare that string into a query, loop through
> all my values and bind them one by one, then execute the query.
You mean something like:
items=(1,2,5,6,9)
cursor.execute("SELECT ... FROM foo where bar in (%s)" %
','.join('?'*len(items)),items)
? :-)
Oh.. I forgot he said PHP...
SCNR
Tino
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера