Re: postgresql database access failure

From: Date: Mon, 02 May 2011 10:05:56 +0000
Subject: Re: postgresql database access failure
Groups: php.general 
Request: Send a blank email to php-general+get-312619@lists.php.net to get a copy of this message
> >Here's the URL of the relevant manual page: >http://www.php.net/manual/en/function.pg-fetch-result.php > The manual page did not explain the purpose of the text 'die', so was ignored (;)). Anyway, the php code was amended as follows: <?php $db = pg_connect('dbname=databasename user=httpd'); $query = pg_query($db,'SELECT * FROM databasetable'); $value=pg_fetch_result($query,100,0); echo 'list of files' ,$value,'\n'; ?> The result is a web page which shows: list of files12345\n where '12345' corresponds correctly to an equivalent value in row 100 of the database table. However, the query requests the entire table. The php code was then amended as follows, which produces output from the database: <?php $db = pg_connect('dbname=databasename user=httpd'); $query = pg_query($db,'SELECT * FROM databasetable'); $value=pg_fetch_all_columns($query,1); var_dump($value); ?> >My personal recommendation, however, is to drop old-style procedural >drivers and switch to PDO - it's much more convenient to use, IMO. If >you use PDO, you don't need to study the API of various different DB >drivers, and your code can easily switch from one database to another. What does PDO mean, so the relevant parts of the manual can be reviewed? Thank you.

« previous php.general (#312619) next »