From: | Filip Rembiałkowski <plk(dot)zuber(at)gmail(dot)com> |
---|---|
To: | David Johnston <polobo(at)yahoo(dot)com> |
Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: string = any() |
Date: | 2012-01-11 08:02:12 |
Message-ID: | CAP_rwwnmR+Y+_FhWw5VK21+D5jh4y=LrxuABCeq2SJ+KbAi4jg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
W dniu 10 stycznia 2012 22:52 użytkownik David Johnston
<polobo(at)yahoo(dot)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 ,"}
From | Date | Subject | |
---|---|---|---|
Next Message | Kirill Müller | 2012-01-11 10:07:23 | Enumeration of tables is very slow in largish database |
Previous Message | Mike Christensen | 2012-01-11 06:50:31 | Re: Can a function return more then one table? |