Apache 與 PHP 原理

request(test.php) ⇒ apache(server) ⇒ php ⇒ output ⇒ apache ⇒ response

Server:專門處理 request 和 response 的程式

網址的規則是由 server 來決定,Apache預設的設定是檔案路徑

資料庫系統簡介

資料庫:專門處理資料的程式

MySQL

phpmyadmin: 一套 GUI 的 資料庫管理介面

Table 表格基礎

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ac1e18eb-a051-4885-b6aa-2cf293b0ca8e/Untitled.png

MySQL 語法簡介

JOIN

另外把 JOIN 拉出來寫是因為覺得需要花一點時間才可以理解

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/08f5eb26-b3f8-4dc4-933d-e9f489fee88f/Untitled.png

假設有 A 和 B 兩表

A

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/86a88caa-7b1c-4a39-97c6-528f77085ffb/Untitled.png

B

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/6ad9e2c7-03b5-4f1c-b16b-8edf657c9e0a/Untitled.png

INNER JOIN

產生的結果就是 A 和 B 的交集

SELECT * FROM A INNER JOIN B ON A.a_id = B.b_id

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9b4f6ea7-0d1f-457e-899c-fec86af6af20/Untitled.png

LEFT JOIN

產生的結果是 A 的完全集,B表中沒有匹配的則以 NULL 填充

SELECT * FROM A LEFT JOIN B ON A.a_id = B.b_id

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/45f750f4-205f-4537-9d1f-470dbbc7ecc6/Untitled.png

RIGHT JOIN

產生的結果是 B 的完全集,A表中沒有匹配的則以 NULL 填充

SELECT * FROM A RIGHT JOIN B ON A.a_id = B.b_id

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/60751c55-740d-4e0f-b409-a1f6e2424b0f/Untitled.png

OUTER JOIN

產生 A 和 B 的並集,若其中沒有匹配的值,則以 NULL 填充

SELECT * FROM A OUTER JOIN B ON A.a_id = B.b_id

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/89c9694b-2b80-4bd5-b127-91ebe5afed4f/Untitled.png

PHP 執行流程

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4103502d-d2ea-4aa0-bba2-cd812fd08444/Untitled.png

有設定過 server 才會執行 PHP 檔,不然就會直接輸出文字檔

<h1>Now: <?php echo date("Y-m-d H:i:s") ?></h1>