PHP與MYSQL互動函數表學習筆記_PHP教程

來源:互聯網
上載者:User
最近一直在研究php(做為現在的主流開發語言)與MySQL(和PHP搭配之最佳組合),感覺php(做為現在的主流開發語言)與MySQL(和PHP搭配之最佳組合)互動的函數都是過程化的,當然也有MySQL(和PHP搭配之最佳組合)i擴充,物件導向,Java和C#寫多了之後,再寫php(做為現在的主流開發語言),有些不適應,感覺又回到了學C的年代。今天學習了一些函數,記錄下來,以便日後忘記時,可以參考。

說 明 函 數 名 函 數 詳 細 函 數 說 明
建立資料庫連接 MySQL(和PHP搭配之最佳組合)_connect() resource MySQL(和PHP搭配之最佳組合)_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
樣本:$conn = @MySQL(和PHP搭配之最佳組合)_connect("localhost", "username", "password") or dir("不能串連到MySQL(和PHP搭配之最佳組合) Server");
使用該串連必須顯示的關閉串連
建立資料庫連接 MySQL(和PHP搭配之最佳組合)_pconnect() resource MySQL(和PHP搭配之最佳組合)_pconnect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
樣本:$conn = @MySQL(和PHP搭配之最佳組合)_pconnect("localhost", "username", "password") or dir("不能串連到MySQL(和PHP搭配之最佳組合) Server");
使用該串連函數不需要顯示的關閉串連,它相當於使用了串連池
關閉資料庫連接 MySQL(和PHP搭配之最佳組合)_close() $conn = @MySQL(和PHP搭配之最佳組合)_connect("localhost", "username", "password") or die("不能串連到MySQL(和PHP搭配之最佳組合) Server");
@MySQL(和PHP搭配之最佳組合)_select_db("MyDatabase") or die("不能選擇這個資料庫,或資料庫不存在");
echo "你已經串連到MyDatabase資料庫";
MySQL(和PHP搭配之最佳組合)_close();
 
選擇資料庫 MySQL(和PHP搭配之最佳組合)_select_db() boolean MySQL(和PHP搭配之最佳組合)_select_db(string db_name [, resource link_id])
$conn = @MySQL(和PHP搭配之最佳組合)_connect("localhost", "username", "password") or die("不能串連到MySQL(和PHP搭配之最佳組合) Server");
@MySQL(和PHP搭配之最佳組合)_select_db("MyDatabase") or die("不能選擇這個資料庫,或資料庫不存在");
http://www.bkjia.com/PHPjc/508626.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/508626.htmlTechArticle最近一直在研究php (做為現在的主流開發語言) 與MySQL (和PHP搭配之最佳組合) ,感覺php (做為現在的主流開發語言) 與MySQL (和PHP搭配之最佳組...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.