(file) Return to mysql_conn.inc CVS log (file) (dir) Up to [Development] / gantt_manager / src / lib / db

 1 pjaol 1.1 <?php
 2           
 3           class db_handle {
 4           
 5             function conn ()
 6             {
 7               $conf = Conf::instance();
 8               $db_conf = $conf->get("db");
 9               $conn = mysql_pconnect($db_conf['host'],$db_conf['dbuser'],$db_conf['passwd']) 
10           	or die("cannot connect ".mysql_error());
11               $conf->set("dbh",$conn);
12             }
13           
14             function checkConn () {
15               $conf = Conf::instance();
16               if(! $conf->get("dbh")) {
17                 $this->conn();
18               }
19             }
20             function ins ($sql) {
21               $conf = Conf::instance();
22 pjaol 1.1     $this->checkConn();
23               #$this->disconnect();     
24               mysql_select_db($db_conf['dbname'], $conf->get("dbh"));
25               return mysql_query($sql, $conf->get("dbh"));
26             }
27           	
28             function sel ($sql) 
29             {
30               $conf = Conf::instance();
31               $db_conf = $conf->get("db");
32               
33               $this->checkConn();
34               $array = array();
35               mysql_select_db($db_conf['dbname'],$conf->get("dbh")) 
36           	or die("cannot select db ".$db_conf['dbname']." ".mysql_error());
37               $results = mysql_query($sql, $conf->get("dbh")) 
38           	or die("bad select $sql " . mysql_error());
39               while($row = mysql_fetch_assoc($results)) {
40                 $array[]=$row;
41               }
42               mysql_free_result($results);
43 pjaol 1.1     $this->disconnect();
44               return $array;
45             }
46           
47             function del ($sql) {
48               $conf = Conf::instance();
49               $this->checkConn();
50               mysql_query($sql, $conf->get("dbh"));
51             }
52           
53             function disconnect () {
54               $conf = Conf::instance();
55               $conn = $conf->get("dbh");
56               mysql_close($conn);
57               $conf->set("dbh", 0);
58             }
59           }
60           ?>

cvsadmin
Powered by
ViewCVS 0.9.2