日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

解析在PHP中使用mysqli擴(kuò)展庫(kù)對(duì)mysql的操作_PHP教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:淺析PHP繪圖技術(shù)
1、圖片格式:目前網(wǎng)站開發(fā)常見的圖片格式有g(shù)if,jpg/jpeg,png ..... 區(qū)別: gif 圖片壓縮率高,但是只能顯示256色,可能造成顏色的丟失,可以顯示動(dòng)畫 jpg/jpeg 圖片壓縮率高(有損壓縮),可以用較小的文件來(lái)顯示,網(wǎng)頁(yè)上用得比較多 png 該格式綜合了gif和jpg的優(yōu)勢(shì),缺

本篇文章是對(duì)在PHP中使用mysqli擴(kuò)展庫(kù)對(duì)mysql的操作進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下  

1、在PHP中 使用mysqli擴(kuò)展庫(kù)對(duì)mysql 的dql操作

復(fù)制代碼 代碼如下:
<?php
    header("Content-type: text/html;charset=utf-8");
    //mysqli操作mysql數(shù)據(jù)庫(kù)(面向?qū)ο蠓绞?
    //1、創(chuàng)建MySQLi對(duì)象
    $mysqli =new MySQLi("localhost","root","root","test");
    if($mysqli->connect_error){
        die("連接失敗".$mysqli->connect_error);
    }
    //2、操作數(shù)據(jù)庫(kù)(發(fā)送sql)
    $sql="select *from user1";
    //3、處理結(jié)果
    $res =$mysqli->query($sql);
    //var_dump($res);
    //fetch_assoc \fetch_array \fetch_object
    while($row=$res->fetch_row()){
        var_dump($row);
/*        foreach($row as $val){
            echo '--'.$val;
        }
        echo '<br/>';*/
    }
    //4、關(guān)閉資源
    $res->free();
    $mysqli->close();
?>


下面是面向過程的

復(fù)制代碼 代碼如下:
<?php
    header("Content-type: text/html;charset=utf-8");

    $mysqli=mysqli_connect("localhost","root","root","test");
    if(!$mysqli){
        die("連接失敗".mysqli_connect_error());
    }
    $sql="select *from user1";
    $res=mysqli_query($mysqli,$sql);
    //var_dump($res);
    while($row=mysqli_fetch_row($res)){

        foreach ($row as $val){

            echo '-'.$val;
        }
        echo '<br/>';
    }
    //釋放內(nèi)存
    mysqli_free_result($res);
    mysqli_close($mysqli);
?>


2、在PHP中 使用mysqli擴(kuò)展庫(kù)對(duì)mysql 的dml操作

復(fù)制代碼 代碼如下:
<?php

    //使用mysqli 擴(kuò)展庫(kù)對(duì)mysql的crud 操作
    header("Content-type: text/html;charset=utf-8");
    $mysqli = new MySQLi("localhost","root","root","test");
    if($mysqli->connect_error){
        die("連接失敗".$mysql->connect_error);
    }
    //增加一條記錄
    //$sql="insert into user1 (name,password,email,age) values ('lucy',md5('lucy'),'[email protected]',17)";
    //刪除一條記錄
    //$sql="delete from user1 where id =80";
    //更新一條記錄
    $sql="update user1 set age=20 where id=7";
    $res=$mysqli->query($sql);
    if(!$res){
        echo "操作失敗".$mysqli->error;
    }else{
        if($mysqli->affected_rows>0){
            echo "成功";
        }else{
            echo "沒有行受影響";   
        }
    }
    //關(guān)閉資源
    $mysqli->close();
?>


3、進(jìn)行封裝

復(fù)制代碼 代碼如下:


<?
    class SqlHelper{

        private $mysqli;
        //這里先寫死,以后寫死的東西用一個(gè)文件來(lái)配置
        private static $host="localhost";
        private static $user="root";
        private static $pwd="root";
        private static $db="test";
        public function __construct(){

            $this->mysqli=new MySQLi(self::$host,self::$user,self::$pwd,self::$db);
            if($this->mysqli->connect_error){
                die("連接失敗".$this->mysqli->connect_error);
            }
            //設(shè)置字符集
            $this->mysqli->query("set names utf8");
        }
        //dql operate
        function execute_dql($sql){
            $res =$this->mysqli->query($sql) or die($this->mysqli->error);
            return $res;       
        }
        //dml operate
        function execute_dml($sql){
            $res =$this->mysqli->query($sql) or die($this->mysqli->error);

            if(!$res){
                return 0;//失敗
            }else{
                if($this->mysqli->affected_rows>0){
                    return 1;//成功
                }else{
                    return 2;//沒有行到影響
                }
            }
        }
    }
?>

分享:解決FastCGI 進(jìn)程超過了配置的活動(dòng)超時(shí)時(shí)限的問題
近日,需要滿足測(cè)試需求,進(jìn)行大數(shù)據(jù)并發(fā)測(cè)試時(shí),報(bào)出【 HTTP 錯(cuò)誤 500.0 - Internal Server Error E:\PHP\php-cgi.exe - FastCGI 進(jìn)程超過了配置的活動(dòng)超時(shí)時(shí)限 】 解決辦法: IIS7-FastCGI設(shè)置-雙擊php-cgi.exe-活動(dòng)超時(shí) 項(xiàng)默認(rèn)是設(shè)置為70(秒),改為600(10分鐘,此處

來(lái)源:模板無(wú)憂//所屬分類:PHP教程/更新時(shí)間:2013-07-04
相關(guān)PHP教程