網(wǎng)站建設(shè)問(wèn)題
文章閱讀
網(wǎng)建技巧
優(yōu)化技巧
網(wǎng)建問(wèn)題
謹(jǐn)宸新聞
行業(yè)新聞

首頁(yè) > 網(wǎng)站建設(shè)問(wèn)題 > 正文

最經(jīng)典的php鏈接操作mysql數(shù)據(jù)庫(kù)類

發(fā)布時(shí)間:2013/10/11字體:
摘要:最經(jīng)典的php鏈接操作mysql數(shù)據(jù)庫(kù)類,mysql操作數(shù)據(jù)庫(kù)的經(jīng)典php類,如果你在尋找php鏈接和操作mysql的數(shù)據(jù)庫(kù)類.本文提供了非常經(jīng)典的類,但是經(jīng)過(guò)本人多次修改和完善,可謂完美,當(dāng)然你可以下載回去再修改和完善。
相信很多人都在搜索php如何鏈接和操作mysql,或者稍微懂點(diǎn)的人都會(huì)搜索php鏈接和操作mysql數(shù)據(jù)庫(kù)的類,算你找對(duì)對(duì)方了。下方我極力推薦一個(gè)php操作mysql的數(shù)據(jù)庫(kù)類,是我多年改寫(xiě)的質(zhì)量不錯(cuò)的版本,你可以拿回去再完善。當(dāng)然,我不保證完全安全。

<?php
class db{
    var $Record = array();var $Link_ID  = 0;var $Query_ID = 0;
    function db(){    
        if(!$this->Link_ID){
            $this->Link_ID=mysql_connect('localhost','root','123');//在這里填寫(xiě)mysql數(shù)控的地址、用戶、密碼即可
            mysql_select_db('fangsongle',$this->Link_ID);
        }
        mysql_query("set names 'utf8'",$this->Link_ID);//此處務(wù)必使用set names 'utf8',不能使用set names utf8
    }
    function insert_id(){return mysql_insert_id($this->Link_ID);}
    function query($sql){
        $this->Query_ID = mysql_query($sql);
        if(!$this->Query_ID) {return 0;}
        return $this->Query_ID;
    }
    function next_record() {
        if(!$this->Query_ID) {return 0;}
        $this->Record = mysql_fetch_array($this->Query_ID);
        if(!is_array($this->Record)) {return 0;}
        return $this->Record;
    }
    function query_first($sql){  
        if(!$this->query($sql)) {return 0;}
        $this->Record = mysql_fetch_array($this->Query_ID);
        return $this->Record;
    }
    function num_rows() {return mysql_num_rows($this->Query_ID);}
    function f($field) {if(isset($this->Record[$field])) {return $this->Record[$field];}}
}
$db=new db();
?>
希望這個(gè)php操作控制mysql的類可以幫到你。
本文標(biāo)題:最經(jīng)典的php鏈接操作mysql數(shù)據(jù)庫(kù)類
本文網(wǎng)址:http://www.bailzz.com/wangjianwenti/2854.html
原創(chuàng)網(wǎng)址:合肥網(wǎng)絡(luò)公司<謹(jǐn)宸科技> 版權(quán)所有,轉(zhuǎn)載請(qǐng)注明出處,并以鏈接形式鏈接網(wǎng)址:www.bailzz.com
文章標(biāo)簽:mysql數(shù)據(jù)庫(kù)
 上一篇:網(wǎng)站優(yōu)化中h1、h2、h3等標(biāo)簽的具體用法
 下一篇:php非常好的一個(gè)表單驗(yàn)證類