OSDN Git Service

add error check and messages.
[pukiwiki/pukiwiki.git] / pgsql.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: pgsql.php,v 1.1 2003/01/27 05:44:11 panda Exp $
6 //
7
8 function db_exec($sql)
9 {
10         $conn = pg_pconnect(PG_CONNECT_STRING)
11                 or die_message('cannot connect db.');
12         $result = pg_query($conn,$sql)
13                 or die_message("query '$sql' failure.");
14         return $result;
15 }
16
17 function db_query($sql)
18 {
19         $result = db_exec($sql);
20         
21         $rows = array();
22         while ($row = pg_fetch_array($result)) {
23                 $rows[] = $row;
24         }
25         pg_free_result($result);
26         
27         return $rows;
28 }
29
30 /*
31 create table page (id serial primary key, name text not null, lastmod integer not null);
32 create table link (page_id integer not null, ref_id integer not null);
33 grant all on page,link,page_id_seq to apache;
34 */
35 ?>