W dniu 10 stycznia 2012 22:52 użytkownik David Johnston
<[email protected]> 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 ,"}
--
Sent via pgsql-general mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general