woff 發表於 2009-12-25 01:06:49

解釋一個數據庫存分類

private $db_host; //數據庫主機
private $db_user; //數據庫用戶名
private $db_pwd; //數據庫用戶名密碼
private $db_database; //數據庫名
private $conn; //數據庫連接標識;
private $coding; //數據庫編碼,GBK,UTF8,gb2312
public function __construct($db_host, $db_user, $db_pwd, $db_database, $conn, $coding) {
$this->db_host = $db_host;
$this->db_user = $db_user;
$this->db_pwd = $db_pwd;
$this->db_database = $db_database;
$this->conn = $conn;
$this->coding = $coding;
$this->connect();
}
/*數據庫連接*/
public function connect() {
if ($this->conn == "pconn") {
   //永久鏈接
   $this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
} else {
   //即使鏈接
   $this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
}
if (!mysql_select_db($this->db_database, $this->conn)) {
   if ($this->show_error) {
    $this->show_error("數據庫不可用:", $this->db_database);
   }
}
mysql_query("SET NAMES $this->coding");
}

$db = new action($mydbhost, $mydbuser, $mydbpw, $mydbname, ALL_PS, $mydbcharset);

這是MYSQL分類,我不明白永久聯接if ($this->conn == "pconn") 這條語句是什麼時意思呀,CONN為數據庫連接標識;初始化時給了賦了一個值ALL_PS,這個ALL_PS是什麼呀,是自定義變量,但是我沒有查文件中看到ALL_PS有什麼值賦給他,請高手回答一下,
還有就是永久連接和即使連接有什麼區別呀?????


謝謝各位的回答,今天是平安夜,祝大家平安夜快樂!
頁: [1]
查看完整版本: 解釋一個數據庫存分類