国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

php操作mysql的類!

2024-07-24 12:57:08
字體:
來源:轉載
供稿:網(wǎng)友
<?
# all text and code within this file are (c)opyright
# pangolin software limited 2000.
#
# you may edit this file to customise it for your web-site,
# however, the actual source code may not be altered in
# any way without the prior written permission of pangolin
# software limited.
# this file is part of the pangolin vote distribution.
# contact: [email protected] or www.pango.co.uk for more info.
/*
* utility routines for mysql.
* modified from code from: http://www.webwizard.com/tutorials/mysql/
*/
class mysql_class {
    # make sure you fill in the values below for your web-site.
    # they are for user,password,host and database respectively.
    #
    var $user = "username";
    var $pass = "password";
    var $thedatabase ="database";
    var $host = "localhost";

    var $db, $id, $result, $rows, $data, $a_rows;
    /*
     * it's a minor security hole to have the username and password
     * appear here.  generally there isn't any way of getting around it
     * if you're using a commercial web hosting service.  there are other
     * ways if it's your own web server.
     */
    function setup ($user, $pass) {
        $this->user = $user;
        $this->pass = $pass;
    }
    function create () {
        $db=$this->thedatabase;
        $this->db = $db;
        $crash=0;
        $this->id = @mysql_pconnect($this->host, $this->user, $this->pass) or
        $crash=1;
        if ($crash==1) {
            mysql_errormsg("unable to connect to mysql server: $this->host - either your username, password or database values are incorrect in vutil.php3 or you have not started mysql on your web server!");
            die("<p>unable to continue.<p>");
            }
        $this->selectdb($db);
    }
    function selectdb ($db) {
        $crash=0;
        @mysql_select_db($db, $this->id) or $crash=1;
        if ($crash==1)
        {
        mysql_errormsg ("unable to select database: $db : the value in vutil.php3 may be incorrect.");
        die ("<p>unable to continue.<p>");
        }
    }
    # use this function is the query will return multiple rows.  use the fetch
    # routine to loop through those rows.
    function query ($query) {
        $this->result = @mysql_query($query, $this->id) or
            mysql_errormsg ("unable to perform query: $query");
        $this->rows = @mysql_num_rows($this->result);
        $this->a_rows = @mysql_affected_rows($this->result);
    }
    # use this function if the query will only return a
    # single data element.
    function queryitem ($query) {
        $this->result = @mysql_query($query, $this->id) or
            mysql_errormsg ("unable to perform query: $query");
        $this->rows = @mysql_num_rows($this->result);
        $this->a_rows = @mysql_affected_rows($this->result);
        $this->data = @mysql_fetch_array($this->result) or mysql_errormsg ("unable to fetch.");
        return($this->data[0]);
    }
    # this function is useful if the query will only return a
    # single row.
    function queryrow ($query) {
        $this->result = @mysql_query($query, $this->id) or
            mysql_errormsg ("unable to perform query: $query");
        $this->rows = @mysql_num_rows($this->result);
        $this->a_rows = @mysql_affected_rows($this->result);
        $this->data = @mysql_fetch_array($this->result) or mysql_errormsg ("unable to fetch.");
        return($this->data);
    }
    function fetch ($row) {
        @mysql_data_seek($this->result, $row) or mysql_errormsg ("unable to seek data.");
        $this->data = @mysql_fetch_array($this->result) or mysql_errormsg ("unable to fetch.");
    }
    function insert ($query) {
        $this->result = @mysql_query($query, $this->id) or
            mysql_errormsg ("unable to perform insert: $query");
        $this->a_rows = @mysql_affected_rows($this->result);
    }
    function update ($query) {
        $this->result = @mysql_query($query, $this->id) or
            mysql_errormsg ("unable to perform update: $query");
        $this->a_rows = @mysql_affected_rows($this->result);
    }
    function delete ($query) {
        $this->result = @mysql_query($query, $this->id) or
            mysql_errormsg ("unable to perform delete: $query");
        $this->a_rows = @mysql_affected_rows($this->result);
    }
}
/* ********************************************************************
* mysql_errormsg
*
* print out an mysql error message
*
*/
function mysql_errormsg ($msg) {
    # close out a bunch of html constructs which might prevent
    # the html page from displaying the error text.
    echo("</ul></dl></ol</n");
    echo("</table></script>/n");
    # display the error message
    $text  = "<font color=/"#ff0000/"><p><b>error: $msg :";
    $text .= mysql_error();
    $text .= "</b></font>/n";
    $errormsg=$text;
    # get rid of unable to fetch error messages
    if (strpos($errormsg,"unable to fetch")==false)
    print "$errormsg/n";
}
?>

最大的網(wǎng)站源碼資源下載站,

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 云林县| 榕江县| 潜江市| 铁力市| 岳阳县| 凉城县| 花垣县| 英吉沙县| 喀喇沁旗| 怀宁县| 新田县| 许昌县| 铜梁县| 昭苏县| 辽中县| 乌兰察布市| 循化| 新竹县| 达孜县| 临桂县| 高邮市| 邢台市| 北宁市| 梨树县| 视频| 衢州市| 安多县| 晋城| 济宁市| 金塔县| 克东县| 偃师市| 宜兰县| 酒泉市| 静海县| 新民市| 田东县| 吉水县| 南和县| 滁州市| 博兴县|