Re: string = any()
| От | Filip Rembiałkowski |
|---|---|
| Тема | Re: string = any() |
| Дата | |
| Msg-id | CAP_rwwnmR+Y+_FhWw5VK21+D5jh4y=LrxuABCeq2SJ+KbAi4jg@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: string = any() ("David Johnston" <polobo@yahoo.com>) |
| Список | pgsql-general |
W dniu 10 stycznia 2012 22:52 użytkownik David Johnston
<polobo@yahoo.com> napisał:
> If you are going to supply one parameter per "possible value" anyway skip the whole "ANY" and "ARRAY" and just say "
'bob'IN ($1, $2 [,...]) ";
true :-)
<?php
$names = array( "joe", "bob" );
$placeholders = implode( ",", array_map( function($x){return "?"}, $names ) );
$sql = "select 'bob' IN ($placeholders)";
$stmt = $dbh->prepare($sql);
$stmt->execute($names);
?>
PHP from several years cries for postgres array support in PDO. And
personally I would rather discourage programmers from constructing
delimited array string in code - more complicated than first option,
needs careful character escaping, etc.
select array['a',null,'','tab is ','quote is "','comma is ,'];
array
-------------------------------------------------------
{a,NULL,"","tab is ","quote is \"","comma is ,"}
В списке pgsql-general по дате отправления: