On 02 May 2011 at 11:05, e-letter <inp...@gmail.com> wrote: 

>>
>> 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 (;)).

What, you mean this?

     $db = pg_connect("dbname=users user=me") || die();

It's what I would call an ugly and unreadable way of handing errors. Personally 
I'd do this:

     $db = pg_connect("dbname=users user=me");
     if  ($db===false)
          {
          // Do any error handling (such as writing to my log file) here
          die ();
          }

And which manual page are you talking about? die() is a function so it's 
trivial to search for it in the functions list using the search facility on all 
PHP documentation pages.

> 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.

Go to the PHP Manual front page, scroll down to Database Extensions under 
Function Reference.

I think you need to learn to find stuff for yourself in the manual. Finding 
PDO, die(), and pg_query (which you initially missed altogether) should be easy 
enough.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to