/[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.7 - (show annotations)
Thu Sep 5 08:52:21 2002 UTC (21 years, 7 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +1 -0 lines
bla

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

  ViewVC Help
Powered by ViewVC 1.1.26