/[fcproducts]/conn.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 /conn.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Wed Jun 6 03:18:29 2001 UTC (18 years, 3 months ago) by ravilov
Branch point for: MAIN, pliva
Initial revision

1 ravilov 1.1 <?php
2     include("class.DBI");
3     function DBOpen($db = "fcproducts", $user = "dpavlin", $pass = "", $host = "", $DBD = "Pg") {
4     global $DBH;
5     if ($DBH && $DBH->dbh) return;
6     $str = "dbi:$DBD:$db";
7     if ($host) $str .= ";host=$host";
8     $DBH = new DBI($str, $user, $pass);
9     if (!$DBH->dbh) {
10     $err = "";
11     if ($DBH) $DBH->errstr;
12     if (!$err) $err = "???";
13     echo "<PRE>[Cannot connect to &quot;$db&quot;: $err]</PRE><BR>\n";
14     unset($GLOBALS['DBH']);
15     exit;
16     }
17     $DBH->dbh_do("SET DATESTYLE='ISO'");
18     }
19     function DBClose() {
20     global $DBH;
21     if (!$DBH || !$DBH->dbh) return;
22     $DBH->disconnect();
23     unset($GLOBALS['DBH']);
24     }
25     function &DBQuery($q) {
26     global $DBH;
27     if (!$DBH || !$DBH->dbh) return array();
28     $DBH->errstr = "";
29     $ret = array();
30     if (eregi('^\s*SELECT', $q)) {
31     $sth = $DBH->prepare($q);
32     if (!$sth) return array();
33     $sth->execute();
34     $ret = array();
35     while ($row = $sth->fetchrow_array())
36     array_push($ret, $row);
37     $sth->finish();
38     } else
39     array_push($ret, $DBH->dbh_do($q));
40     return $ret;
41     }
42     ?>

  ViewVC Help
Powered by ViewVC 1.1.26