Re: first steps in PhP and PostgreSQL

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: first steps in PhP and PostgreSQL
Дата
Msg-id 454F49C7.9010203@archonet.com
обсуждение исходный текст
Ответ на first steps in PhP and PostgreSQL  (Desmond Coughlan <coughlandesmond@yahoo.fr>)
Список pgsql-general
Desmond Coughlan wrote:
>   <?php
>   pg_connect ("dbname=cdi user=cdi password=toto") or die
> ("Couldn't Connect: ".pg_last_error());
> $query="SELECT * FROM stock";
> $query=pg_query($query);

Firstly, rewrite this as
   $sql = "SELECT * FROM stock";
   $res = pg_query($sql);

   echo "pg_query($sql) = $res<br>";
   echo "num rows = ".pg_num_rows($res)."<br>";

>   // start the output
>   while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
> echo "Title: ".$row['isbn_no']."<br />";
> echo "blah ".$row['code_livre']."<br />";
> }
>   ?>

Now you'll know what the return-code of pg_query was as well as how manu
rows it returned. Does that help at all?

--
   Richard Huxton
   Archonet Ltd

В списке pgsql-general по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: DISTINCT is not quite distinct
Следующее
От: Tom Lane
Дата:
Сообщение: Re: DISTINCT is not quite distinct