Search Postgresql Archives

Re: string = any()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



W dniu 10 stycznia 2012 22:52 użytkownik David Johnston
<polobo@xxxxxxxxx> 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 (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux