Re: Secure "where in(a,b,c)" clause.

From: "William Temperley" <willtemperley(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Secure "where in(a,b,c)" clause.
Date: 2008-04-04 09:11:35
Message-ID: 439dc11e0804040211k48ce9047wad6c52bb1289b736@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the replies,

"Rodrigo E. De León Plicet" <rdeleonp(at)gmail(dot)com> wrote:
>Use a prepared query and ANY, e.g.:
>select st_collect(the_geom) from tiles
>where tilename = any('{foo,bar,baz}');

Thanks, that's what I was looking for!
$sql = "select uid, accredited as acc, x(the_geom), y(the_geom) from clubs
where st_within(the_geom, (select st_collect(the_geom) from tiles
where tilename = any($1)))";

$result = pg_query_params($sql, array('{'.$tilearr.'}'));

Though a regex would do as well I guess.

Cheers

Will

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Stark 2008-04-04 10:18:09 Re: is it helpful for the optimiser/planner to add LIMIT 1
Previous Message Martijn van Oosterhout 2008-04-04 09:06:01 Re: modules