/[hr-web]/inc/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

Contents of /inc/conn.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Sat Apr 21 08:41:09 2001 UTC (23 years, 1 month ago) by dpavlin
Branch: MAIN
Changes since 1.1: +1 -1 lines
pliva default

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

  ViewVC Help
Powered by ViewVC 1.1.26