class db else else {
return 0;
//釋放結果集
public function free_result() {
$void = func_get_args();
foreach($void as $query) {
if(is_resource($query) && get_resource_type($query) === 'mysql result') {
return mysql_free_result($query);
$this->write_log("釋放結果集");
//獲取最後插入的id
public function insert_id() {
$id = mysql_insert_id($this->link_id);
$this->write_log("最後插入的id為".$id);
return $id;
//關閉資料庫連線
protected function close() {
$this->write_log("已關閉資料庫連線");
return @mysql_close($this->link_id);
//錯誤提示
private function halt($msg='') {
$msg .= "\r\n".mysql_error();
$this->write_log($msg);
die($msg);
//析構函式
public function __destruct() {
$this->free_result();
$use_time = ($this-> microtime_float())-($this->time);
$this->write_log("完成整個查詢任務,所用時間為".$use_time);
if($this->is_log){
fclose($this->handle);
//寫入日誌檔案
public function write_log($msg=''){
if($this->is_log){
$text = date("y-m-d h:i:s")." ".$msg."\r\n";
fwrite($this->handle,$text);
//獲取毫秒數
public function microtime_float() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
mysql語句操作檔案 mysql語句操作
1.從login表中選出name欄位包含admin的前10條結果所有資訊的sql語句 select from login where name like admin limit 0 10 2.查詢user表的結構 desc user 3.顯示哪些執行緒在執行 show processlist 4.顯...
Linux下操作Mysql類
ifndef mysql api define mysql api include include include include include include include include mysql預設埠 define default mysql port 3306 using namesp...
封裝Python操作mysql類
封裝python操作mysql的類 encoding utf 8 import pymysql import time class pymysql class 初始化,規定物件所擁有的屬性 definit self,host 127.0.0.1 user root passwd root db te...