/[libdata]/trunk/include/db_connect.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/include/db_connect.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (hide annotations)
Fri Mar 5 22:38:33 2004 UTC (20 years, 1 month ago) by dpavlin
Original Path: branches/pear-db/db_connect.php
File size: 1272 byte(s)
initial changes to support PEAR::DB. Mostly broken, can it can select.

1 dpavlin 31 <?php
2    
3     /****************************************************************/
4    
5     /* constants */
6 dpavlin 50 $DEBUG = 0; // XXX not used at all?
7 dpavlin 31
8     /****************************************************************/
9    
10     /* database parameters */
11 dpavlin 50 #$dsn = 'mysql://libdata:libdatapw@localhost/libdata';
12     $dsn = 'pgsql://dpavlin@/libdata';
13     $dsn_options = array(
14     'debug' => 2,
15     'portability' => DB_PORTABILITY_ALL,
16     );
17 dpavlin 31
18     /****************************************************************/
19    
20 dpavlin 50 /* establish a connection to the database or bailout */
21     $db =& DB::connect($dsn, $dsn_options);
22     if (DB::isError($db)) {
23     XXX_debug($db->getMessage() ." / ".
24     $db->getUserInfo() . " / ".
25     $db->getDebugInfo());
26     # XXX remove this!
27     print $db->getDebugInfo();
28    
29     die($db->getMessage());
30     }
31 dpavlin 31
32     /****************************************************************/
33    
34    
35     /* some useful functions */
36    
37     /* return an error message from a failed sql query */
38     function sql_err ( $p_sql ) {
39     printf ( "ERROR: Query failed.<br>%s<br>%s: %s<br>\n",
40 dpavlin 42 $p_sql, xx_errno(), xx_error() );
41 dpavlin 31 return 1;
42     }
43    
44     /* finish off the html stream and die */
45     function bailout() {
46     die ( "Bailing Out!<br>\n</body></html>\n" );
47     }
48    
49    
50     ?>

  ViewVC Help
Powered by ViewVC 1.1.26