Search Postgresql Archives

php + postgresql

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

 



First, thanks to everyone who responded to my newbie questions yesterday, all clear now.

I spent most of today struggling with apparently inconsistent behaviour while running SELECT statements on PG 8.1.9 using PHP 5.1.6 (these are both as supplied with CentOS 5.1, a fairly conservative distro).

It seems that some of PHP's PG functions have changed recently, are there any known issues with them?

1.
I ended up using pg_prepare() and pg_execute() as pg_query() alone just didn't seem to work. But SELECT statements seemed to be cached or persistent in some way, such that they "lived" beyond the life of the PHP script. Is there something I need to know about persistent behaviour in PG that doesn't exist in MySQL?


2.
Another problem was that no matter how many times I checked and re-checked code, or which pg_fetch_* function I used, copying an array member and trying to use it later just would not work, eg

while ($row = pg_fetch_array($query)) {
  $content = $row[0]
}

echo $content;

$content was always 'undeclared'.

3.
Some examples I found used PHP's pg_num_rows() function to count the rows in a result, then iterated through them with a "for" loop ... is this required behaviour (PHP docs don't appear to discuss this)?

4.
Another weird one was that this statement always failed:

$name = "file.php";
SELECT fld_content FROM tbl_page WHERE fld_name='$name'

while this one always worked:

SELECT fld_content FROM tbl_page WHERE fld_pid=1

in a three column table:

fld_pid serial PRIMARY KEY,
fld_name varchar(100) NOT NULL,
fld_content text NOT NULL

while everything worked fine from the psql console.


... but this post is getting too unwieldy. I am reading documentation but am also under some pressure to get basic things up and running. Any pointers to good documentation covering PHP + PG, or any well known gotchas?

PS If people want to throw MySQL->PostgreSQL gotchas at me I'm happy to collate and write up.

Thanks again
Mick


[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