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

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

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

發(fā)布時間:2013/10/11字體:
摘要:最經(jīng)典的php鏈接操作mysql數(shù)據(jù)庫類,mysql操作數(shù)據(jù)庫的經(jīng)典php類,如果你在尋找php鏈接和操作mysql的數(shù)據(jù)庫類.本文提供了非常經(jīng)典的類,但是經(jīng)過本人多次修改和完善,可謂完美,當(dāng)然你可以下載回去再修改和完善。
相信很多人都在搜索php如何鏈接和操作mysql,或者稍微懂點的人都會搜索php鏈接和操作mysql數(shù)據(jù)庫的類,算你找對對方了。下方我極力推薦一個php操作mysql的數(shù)據(jù)庫類,是我多年改寫的質(zhì)量不錯的版本,你可以拿回去再完善。當(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');//在這里填寫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();
?>
希望這個php操作控制mysql的類可以幫到你。
本文標(biāo)題:最經(jīng)典的php鏈接操作mysql數(shù)據(jù)庫類
本文網(wǎng)址:http://www.fn9c.com/wangjianwenti/2854.html
原創(chuàng)網(wǎng)址:合肥網(wǎng)絡(luò)公司<謹(jǐn)宸科技> 版權(quán)所有,轉(zhuǎn)載請注明出處,并以鏈接形式鏈接網(wǎng)址:www.fn9c.com
文章標(biāo)簽:mysql數(shù)據(jù)庫
 上一篇:網(wǎng)站優(yōu)化中h1、h2、h3等標(biāo)簽的具體用法
 下一篇:php非常好的一個表單驗證類