get("db"); $conn = mysql_pconnect($db_conf['host'],$db_conf['dbuser'],$db_conf['passwd']) or die("cannot connect ".mysql_error()); $conf->set("dbh",$conn); } function checkConn () { $conf = Conf::instance(); if(! $conf->get("dbh")) { $this->conn(); } } function ins ($sql) { $conf = Conf::instance(); $this->checkConn(); #$this->disconnect(); mysql_select_db($db_conf['dbname'], $conf->get("dbh")); return mysql_query($sql, $conf->get("dbh")); } function sel ($sql) { $conf = Conf::instance(); $db_conf = $conf->get("db"); $this->checkConn(); $array = array(); mysql_select_db($db_conf['dbname'],$conf->get("dbh")) or die("cannot select db ".$db_conf['dbname']." ".mysql_error()); $results = mysql_query($sql, $conf->get("dbh")) or die("bad select $sql " . mysql_error()); while($row = mysql_fetch_assoc($results)) { $array[]=$row; } mysql_free_result($results); $this->disconnect(); return $array; } function del ($sql) { $conf = Conf::instance(); $this->checkConn(); mysql_query($sql, $conf->get("dbh")); } function disconnect () { $conf = Conf::instance(); $conn = $conf->get("dbh"); mysql_close($conn); $conf->set("dbh", 0); } } ?>