1 / 26

PHP MySQL

PHP MySQL. 教材. 葉建榮 著( 2010 ), PHP6 與 MySQL 基礎學習教室, 上奇資訊股份有限公司, ISBN 9789862570500 (書號 HB1004 ) 陳會安 著( 2013 ), PHP+MySQL 與 jQuery Mobile 跨行動裝置網站開發, 碁峰資訊股份有限公司, ISBN 9789862768563 (書號 ACL037900 ). 大綱. 什麼是資料庫 MySQL 資料庫介紹 登入 MySQL MySQL 管理者帳號管理 ( Windows 篇)

uta-winters
Download Presentation

PHP MySQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHPMySQL

  2. 教材 葉建榮 著(2010), PHP6 與 MySQL 基礎學習教室, 上奇資訊股份有限公司, ISBN 9789862570500 (書號 HB1004) 陳會安 著(2013), PHP+MySQL 與 jQuery Mobile 跨行動裝置網站開發, 碁峰資訊股份有限公司, ISBN 9789862768563 (書號 ACL037900)

  3. 大綱 什麼是資料庫 MySQL資料庫介紹 登入MySQL MySQL管理者帳號管理 (Windows篇) MySQL管理者帳號管理(Linux篇)

  4. 什麼是資料庫 • 資料庫的用途 • 快速且正確的新增、刪除、查詢、更改資料 • CRUD • Create • Read • Update • Delete

  5. 什麼是資料庫 • 資料庫:Database • 資料表:Table • 紀錄:Record, Row • 欄位:Field, Column • 資料庫管理系統: Database Management System,DBMS • 管理資料庫、資料存取與控制,提供使用者連線

  6. 什麼是資料庫 資料庫管理系統 DataBase Management System 資料庫 DataBase 資料庫 DataBase 資料表Table 資料表Table 欄位Field 欄位Field

  7. mysql資料庫 `user`: 使用者帳號 `db`: 資料庫存取權限 `host`: 主機存取權限 `tables_priv`: 表格存取權限 `columns_priv`: 欄位存取權限 phpMyAdmin是一套MySQL管理網頁系統,可由http://www.phpmyadmin.com網站下載,解壓縮後放在網站目錄下就可以使用。

  8. MySQL資料庫管理系統 • MySQL採用雙重授權許可 • GNU授權: • 免費使用,Open Source 開放原始碼 • 商業授權: • Commercial License for OEMs, ISVs and VARs • MySQL AB,1995 年,瑞典 • Sun Microsystems 買 MySQL AB (2008年) • Oracle 買 Sun Microsystems (2010年)

  9. ODBC連接方式 • Windows 應用程式利用 ODBC 與 MySQL 溝通 MySQLServer Windows 視窗應用程式 ODBC Driver Connector/ODBC Microsoft Access

  10. PHP 連接方式 mysql mysqli pdo

  11. PHP mysql $c = mysql_connect("example.com", "user", "password"); mysql_select_db("database"); $sql = "SELECT 'Hello, dear MySQL user!' AS _msg FROM DUAL"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo htmlentities($row['_msg']);

  12. PHP mysqli $mysqli = newmysqli("example.com", "user", "password", "database"); $sql = "SELECT 'Hello, dear MySQL user!' AS _msg FROM DUAL"; $result = $mysqli->query($sql); $row = $result->fetch_assoc(); echo htmlentities($row['_msg']);

  13. PHP pdo $pdo = newPDO('mysql:host=example.com;dbname=database', 'user', 'password'); $sql = "SELECT 'Hello, dear MySQL user!' AS _msg FROM DUAL"; $statement = $pdo->query($sql); $row = $statement->fetch(PDO::FETCH_ASSOC); echo htmlentities($row['_msg']);

  14. 安全性 MySQL Server 第二道驗證程序 第一道驗證程序 向MySQL Server提出連線需求 驗證失敗 驗證失敗 顯示驗證失敗訊息 顯示驗證失敗訊息 第一道驗證程序:檢查登入帳號的host、username、password 第二道驗證程序:檢查檢查存取權限

  15. 伺服器環境設定

  16. 練習: 建立資料表 • 建立一個資料表 `user` 包括下列欄位 • `account` varchar(20) primary key • `name` varchar(20) • `passwd` varchar(50) • `email` varchar(50) • `note` text • `last_modified` timestamp default CURRENT_TIMESTAMP

  17. 練習: 建立資料表 CREATE TABLE IF NOT EXISTS `user` ( `account` varchar(20) NOT NULL, `name` varchar(20) NOT NULL, `passwd` varchar(50) NOT NULL, `email` varchar(50) NULL, `note` text, `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`account`), UNIQUE KEY `email` (`email`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

  18. 練習: 建立資料表

  19. 練習: 插入資料 INSERT INTO `db10116E001`.`user` (`account`, `name`, `passwd`, `email`, `note`, `last_modified`) VALUES ('garry', '許蓋功', PASSWORD('1234'), 'garry@csie.cust.edu.tw', NULL, CURRENT_TIMESTAMP), ('martin', '馬丁', PASSWORD('1234'), 'martin@csie.cust.edu.tw', NULL, CURRENT_TIMESTAMP), ('jack', '陳傑克', PASSWORD('1234'), 'jack@csie.cust.edu.tw', '欠管理費', CURRENT_TIMESTAMP), ('luc', '呂克強', PASSWORD('12345'), 'luc@csie.cust.edu.tw', '馬丁介紹', CURRENT_TIMESTAMP), ('mary', '蔡瑪莉', PASSWORD('2345'), 'mary@csie.cust.edu.tw', NULL, CURRENT_TIMESTAMP);

  20. 練習: 列出資料 建立一個 PHP 網頁,以表格列出 `user` 內容 使用 mysql 使用 mysqli

  21. 使用 mysql

  22. conn.inc.php

  23. style.css

  24. 使用 mysqli

More Related