public function __construct($host,$user,$pass,$name,$font){
$this->host=$host;
$this->user=$user;
$this->pass=$pass;
$this->name=$name;
$this->font=$font;
$this->init_conn();
}
//執行sql語句
public function _query($sql){
if(!$this->result=mysql_query($sql,$this->conn)){
exit('sql執行失敗');
}
return $this->result;
}
//查詢單挑資料
public function _fetch_array($sql){
$this->_query($sql);
$this->rowRst=mysql_fetch_array($this->result,MYSQL_ASSOC);
return $this->rowRst;
}
//查詢多條資料
public function _fetch_array_list($sql){
$this->_query($sql);
while (!!$rows=mysql_fetch_array($this->result,MYSQL_ASSOC)){
$this->rowArray[]=$rows;
}
return $this->rowArray;
}
//增改刪的影響記錄條數
public function _affected_rows(){
$this->rowAff=mysql_affected_rows();
return $this->rowAff;
}
//取得上一步INSERT操作的ID號
public function _insert_id(){
return mysql_insert_id();
}
//釋放結果集
public function _free_result(){
$this->rowAff='';
$this->rowArray='';
$this->rowRst='';
mysql_free_result($this->result);
}
//關閉資料庫
public function _close_conn(){
$this->_free_result();
mysql_close($this->conn);
}
}
當我用_close_conn這個方法是,網頁面顯示mysql_free_result():supplied argument is not a valid mysql result resource
如何解決這個問題