T Started Fast With PHP - MySQL
T Started Fast With PHP - MySQL
C1, Slide 1
1.1. Introduction to web development with PHP
2
1.1. Introduction to web development with PHP (tt)
3
1.1. Introduction to web development with PHP (tt)
4
1.1. Introduction to web development with PHP (tt)
5
1.1. Introduction to web development with PHP (tt)
6
1.1. Introduction to web development with PHP (tt)
7
1.1. Introduction to web development with PHP (tt)
8
1.1. Introduction to web development with PHP (tt)
Cách đổi cổng cho Localhost
http://localhost:8080 thay vì chỉ là http://localhost.
9
1.1. Introduction to web development with PHP (tt)
Cài Đặt Visual Studio Code
B1. Tải Visual Studio Code theo đường dẫn: https://code.visualstudio.com
B2. Chạy file cài đặt VSCodeUserSetup-....exe và tiến hành cài đặt
10
1.1. Introduction to web development with PHP (tt)
Navicat Premium 12 là một công cụ phát triển cơ sở dữ liệu cho phép kết nối đồng thời với các cơ sở dữ liệu
MySQL, MariaDB, SQL Server, Oracle, PostgreSQL và SQLite từ một ứng dụng duy nhất.
Hướng dẫn Cài đặt bản Full Crack
Bước 1. Tải File Navicat Premium 12.
Bước 2. Ngắt kết nối Internet và phần
mềm diệt Virus
Bước 3. Giải nén và chạy File Setup để
cài đặt.
Bước 4. Sau khi cài đặt thành công, tắt
phần mềm đi.
Bước 5. Chạy file “Keygen_Patch”
dưới quyền admin (Run as
administrator) và sau đó nhấn Patch để
lấy key.
Bước 6. Sau khi Crack thành công.
Khởi động lại phần mềm và sử dụng.
11
1.1. Introduction to web development with PHP (tt)
12
1.1. Introduction to web development with PHP (tt)
13
1.2. How to use PHP with a Mysql database
Objectives
1. Describe the PHP code for creating a PDO object that connects to a
MySQL database.
2. Describe the PHP code for handling the PDO exceptions that may occur
when you try to create a PDO object.
3. List two reasons you should use prepared statements for production
applications.
4. Describe how to use a prepared statement to execute a SELECT,
INSERT, UPDATE, or DELETE statement.
5. Describe a PHP array and the way that numeric and string indexes are
used to access the data in a PHP array.
6. Distinguish between the fetch() and fetchAll() methods of the
PDOStatement class.
7. Describe how to use a foreach statement to get data from all rows of a
result set.
14
1.2. How to use PHP with a Mysql database (tt)
PHP PDO
The PHP Data Objects (PDO) defines a lightweight interface for accessing
databases in PHP. It provides a data-access abstraction layer for working with
databases in PHP. It defines consistent API for working with various database
systems.
15
1.2. How to use PHP with a Mysql database (tt)
The syntax for creating an object from any class
$objectName = new ClassName(arguments);
The syntax for creating a database object from the PDO class
$objectName = new PDO($dsn, $username, $password);
The syntax for a DSN (Data Source Name) for a MySQL database
mysql:host=host_address;dbname=database_name
The DSN is the Data Source Name, which contains the information required to
connect to the database.
16
1.2. How to use PHP with a Mysql database (tt)
How to connect to a MySQL database
$dsn = 'mysql:host=localhost;dbname=my_guitar_shop1';
$username = 'root';
$password = '123456';
A new PDO object is created. We pass the constructor the data source name
and the user name and password. The PDO class represents a connection
between PHP and a database server.
http://zetcode.com/php/pdo/ 17
1.2. How to use PHP with a Mysql database (tt)
18
1.2. How to use PHP with a Mysql database (tt)
19
1.2. How to use PHP with a Mysql database (tt)
20
1.2. How to use PHP with a Mysql database (tt)
21
1.2. How to use PHP with a Mysql database (tt)
22
1.2. How to use PHP with a Mysql database (tt)
23
1.2. How to use PHP with a Mysql database (tt)
24
1.2. How to use PHP with a Mysql database (tt)
25
1.2. How to use PHP with a Mysql database (tt)
26
1.2. How to use PHP with a Mysql database (tt)
27
1.2. How to use PHP with a Mysql database (tt)
The user interface
28
1.3. How to use the MVC patern to organize your code
Objectives
1. Describe the Model-View-Controller pattern.
2. Describe the code for creating and calling a function.
3. How to redirect to another webpage.
29
1.3. How to use the MVC patern to organize your code (tt)
MVC Architecture
MVC is a software architectural pattern for implementing user interfaces on
computers. It divides a given application into three interconnected parts.
- MVC stands for "Model view And Controller"
- The main aim of MVC Architecture is to separate the Business logic &
Application data from the USER interface.
- The main advantage of Architecture is Reusability, Security and Increasing the
performance of Application.
Model: Database operation such as fetch data or update data etc.
View: End-user GUI through which user can interact with system, i.e., HTML,
CSS.
Controller: Contain Business logic and provide a link between model and
view.
30
1.3. How to use the MVC patern to organize your code (tt)
31
1.3. How to use the MVC patern to organize your code (tt)
32
1.3. How to use the MVC patern to organize your code (tt)
33
1.3. How to use the MVC patern to organize your code (tt)
34
1.3. How to use the MVC patern to organize your code (tt)
35
1.3. How to use the MVC patern to organize your code (tt)
36
Q&A
37