Semi-newbie - postgres polygon/points and PHP?
| From: | Roger Southwick | Date: | Sat, 16 Feb 2002 08:18:38 +0000 |
| Subject: | Semi-newbie - postgres polygon/points and PHP? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-16988@lists.php.net to get a copy of this message | ||
Ok, a kinda newbie question. I set up a Postgres DB with a table that had a
Point and a Polygon in it (to hold XY and shape settings for munging a jpeg
image in php).
I could not easily figure out how to extract the data into a reasonably easy
to use format in PHP. The best I could do seemed like it was extracted
into a string, and then I had to parse that.
While this works, it seems like a BIG hack to me, and the docs have been
less then forthcoming.
I've also tried the usual google search of "php postgres polygon" to see if
I could get an idea.
For example, I stored the Point as: (432, 120)
And I got "(432, 120)" as a string, and had to parse it:
...
$Q = "SELECT * FROM room WHERE id=$id";
if(!($Result = pg_exec($Connection, $Q)))
{
print("Query failed $Q");
print(pg_errormessage($Connection));
print("<BR>\n");
exit;
}
$myroom = pg_fetch_array($Result, $i);
$xy = $myroom["xy"];
$xyar = split("[\(,\)]", $xy);
$x = $xyar[1];
$y = $xyar[2];
...
Any ideas?