<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 78  文章 - 25  trackbacks - 0
    <2009年7月>
    2829301234
    567891011
    12131415161718
    19202122232425
    2627282930311
    2345678

    常用鏈接

    留言簿

    隨筆分類(75)

    隨筆檔案(78)

    相冊

    實用Links

    我的Links

    搜索

    •  

    積分與排名

    • 積分 - 114113
    • 排名 - 516

    最新評論

    閱讀排行榜

    評論排行榜

    數據庫高級操作
    (1)獲取報錯信息mysql_error(),mysql_errno()
    string mysql_error([resource $link_identifier]);返回上一個mysql函數的錯誤文本,如果沒有出錯則返回空字符串
    int mysql_errno([resource $link_identifier]);返回上一個mysql函數的錯誤號碼,如果沒有出錯則返回0
    例如:選擇一個不存在的數據庫會出錯,在一個已經存在的數據庫中,操作一個不存在的表也會出錯。

    (2)獲取數據庫和表的信息
    mysql_list_dbs(),
    mysql_db_name(),
    mysql_list_tables(),
    mysql_tablename()
    具體用法:
    resource mysql_list_dbs([resource $link_identifier])
    string mysql_db_name(resource $result,int $row[,mixed $field])
    resource mysql_list_tables(string $databaseName[,resource $link_identifier])
    string mysql_tablename(resource $result,int $i)
    (3)
    ▼mysql_free_result()釋放內存
    ▼mysql_num_rows()判斷結果指針中所指記錄的個數
    <?php
        #連接數據庫
        $link=mysql_connect("localhost","root","root");
        //選擇數據庫--不存在的數據庫,出錯
        mysql_select_db("noexistentdb");
        echo mysql_error()."<br>";

        mysql_select_db("rorely");
        #查詢不存在的表,出錯
        mysql_query("select * from noexistenttable");
        echo mysql_error()."<hr>";

        #輸出數據庫列表
        $db_list=mysql_list_dbs($link);
        while($row=mysql_fetch_object($db_list)) echo $row->Database."<br>";
        echo"<hr>";

        #輸出數據庫列表中所有數據庫的名稱
        $i=0;
        $count=mysql_num_rows($db_list);
        while($i<$count){
            echo mysql_db_name($db_list,$i)."<br>";
            $i++;
        }
        echo"<hr>";

        #輸出數據庫列表中所有的所有表mysql_list_tables(dbname)
        $result=mysql_list_tables("mysql");
        if(!$result) {
            print "DB error,could not list tables<br>";
            print "MySQL error:".mysql_error();
            exit;
        }
        while($row=mysql_fetch_row($result))
            print "Table:$row[0].<br>";
            
        mysql_free_result($result);
        echo"<hr>";

        #輸出數據庫表mysql_tablename(resource)
        $result=mysql_list_tables("rorely");
        for($i=0;$i<mysql_num_rows($result);$i++){
            printf("Table:%s<br>",mysql_tablename($result,$i));
        }
        mysql_free_result($result);
    ?>

    輸出結果如下:
    Unknown database 'noexistentdb'
    Table 'rorely.noexistenttable' doesn't exist
    information_schema
    mysql
    rorely
    test

    information_schema
    mysql
    rorely
    test

    Table:columns_priv.
    Table:db.
    Table:event.
    Table:func.
    Table:general_log.
    Table:help_category.
    Table:help_keyword.
    Table:help_relation.
    Table:help_topic.
    Table:host.
    Table:ndb_binlog_index.
    Table:plugin.
    Table:proc.
    Table:procs_priv.
    Table:servers.
    Table:slow_log.
    Table:tables_priv.
    Table:time_zone.
    Table:time_zone_leap_second.
    Table:time_zone_name.
    Table:time_zone_transition.
    Table:time_zone_transition_type.
    Table:user.

    Table:test
    posted on 2009-07-02 09:02 期待明天 閱讀(334) 評論(0)  編輯  收藏 所屬分類: PHP
    主站蜘蛛池模板: 人成午夜免费视频在线观看| 久久综合给合久久国产免费| 免费的涩涩视频在线播放| 亚洲最新视频在线观看| 久久久久久AV无码免费网站| 久久精品国产精品亚洲精品 | 免费看一级做a爰片久久| 亚洲av永久中文无码精品综合| 在线播放高清国语自产拍免费| 亚洲第一男人天堂| 成人免费午夜视频| 综合偷自拍亚洲乱中文字幕| 国产免费私拍一区二区三区| 成年大片免费高清在线看黄| 中文字幕亚洲激情| 久久久久久久99精品免费观看 | 成在线人永久免费视频播放| 亚洲av无码专区青青草原| 国产片免费福利片永久| 男女男精品网站免费观看| 亚洲三区在线观看无套内射| 免费无码中文字幕A级毛片| 亚洲精品午夜在线观看| 毛片在线免费视频| 一级a性色生活片久久无少妇一级婬片免费放 | 在线观看免费人成视频色9| 久久亚洲AV成人无码国产电影 | 69式互添免费视频| 亚洲欧美日韩中文字幕一区二区三区| 四虎永久免费影院| 永久免费av无码网站yy| 亚洲免费闲人蜜桃| 亚洲国产成人VA在线观看| 免费一级不卡毛片| 亚洲熟妇无码AV| 亚洲精品午夜无码专区| 免费三级毛片电影片| 免费一级全黄少妇性色生活片| 日韩亚洲Av人人夜夜澡人人爽 | 99视频有精品视频免费观看| 亚洲日本成本人观看|