Re: [GENERAL] PHP and Postgres arrays

2008-01-18 Thread Yannick Warnier

Le vendredi 18 janvier 2008 à 23:10 +0100, Ivan Sergio Borgonovo a
écrit :
 On Fri, 18 Jan 2008 23:01:09 +0100
 Yannick Warnier [EMAIL PROTECTED] wrote:
 
  Hello,
 
  I've been searching (not very thoroughly, but still) for a way to
  get Postgres arrays right into PHP arrays, but it seems that the
  Postgres driver simply doesn't allow that.
 
 What about using a stored procedure to return the array as a joined
 row?

I thought about it, but it's not very portable if you want to ship a PHP
application. But I admit I will fall back to that solution if I cannot
find any other (considering PostgreSQL might be the only open-source
database to offer in-fields arrays anyway).

Yannick


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[GENERAL] PHP and Postgres arrays

2008-01-18 Thread Yannick Warnier
Hello,

I've been searching (not very thoroughly, but still) for a way to get
Postgres arrays right into PHP arrays, but it seems that the Postgres
driver simply doesn't allow that.

The only solution seems to use some user-defined functions[1] to split
the result of a query (a string) into a PHP array.

Some Perl-related readings [2] seem to say that Postgres actually
provides a string, loosing the possibility to get it as an array, but
these comments date back to 2005.

Any chance someone around here might tell me more about this and
possibly give me some better way to get those arrays than copy-pasting
the user-proposed PHP functions?

Thanks,

Yannick Warnier

[1] http://www.php.net/manual/en/ref.pgsql.php#58660
[2] http://www.perlmonks.org/?node_id=474518


---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] GiST and Gin technical doc

2006-10-01 Thread Yannick Warnier
Hi there,

I'm having trouble finding technical documentation about GiST, Gin and
TSearch2.

I am particularly interested in the internal data structure of a GiST-ed
or Gin-ed index, and the availability of searches by proximity.

Does anyone know of a good place to find such doc, outside from the
source code (I'm not too much into C/C++)?

Thank you,

Yannick


---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] People near me query

2004-03-19 Thread Yannick Warnier
Le ven 19/03/2004 à 11:05, David Garamond a écrit :
 Imagine an Orkut-like site. Suppose we have 'person' table of 100k 
 people. About 75% of these people fill in their location 
 (City/State/Country) information. We also have a 'city' table containing 
 list of cities with their state  country and each city's 
 latitude/longitude. Assume all people's location is registered in the 
 'city' table.
 
 How does one design a database to be able to process Show me people 
 that live no farther than 250 miles from where I live quickly? I can do 
 Show me people that live within (A-X to A+X) latitude and (B-X to B+X) 
 longitude though. (Where A and B is the latitude and longitude [of the 
 person], and X is some numeric value.

Hi David,

I think the answer depends on the precision you want. Reading your post,
it doesn't seem to me you need a lot of precision.

Usually your technique could do for an approximation. If you want to be
more precise though, you would have to use a completely different
calculation or structure.

Did you think about the fact that longitude is different in terms of
distance if you look it from here or from the equator?
Also, using a difference in terms of longitude and latitude just by
making a subtraction will give you persons which are actually located at
more than sqrt(2) times 250 miles. Making it 350 miles sometimes (and
that's still flying like a bird).

A more precise way of doing this would be to keep a table with distances
between cities, and then calculate your way to your destination by
taking the shorter path (and that's only a question of distance, not
time)... That's really a lot more calculations. It depends on what you
need.

Yannick


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html