Mysqli so với pdo 2022

SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. ...

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.

This example is a Zend Framework example but the theory is the same.

As in:

$sql = <<<____SQL
     CREATE TABLE IF NOT EXISTS `ticket_hist` (
       `tid` int(11) NOT NULL,
       `trqform` varchar(40) NOT NULL,
       `trsform` varchar(40) NOT NULL,
       `tgen` datetime NOT NULL,
       `tterm` datetime,
       `tstatus` tinyint(1) NOT NULL
     ) ENGINE=ARCHIVE COMMENT='ticket archive';
     CREATE TABLE IF NOT EXISTS `request_hist` (
       `rqid` int(11) NOT NULL,
       `rqtid` int(11) NOT NULL,
       `rqsid` int(11) NOT NULL,
       `rqdate` datetime NOT NULL,
       `rqcode` tinyint(1) NOT NULL,
       `rssid` int(11) NOT NULL,
       `rsdate` datetime,
       `rscode` tinyint(1)
     ) ENGINE=ARCHIVE COMMENT='request archive';
     CREATE TABLE IF NOT EXISTS `relay_hist` (
       `rqid` int(5) NOT NULL,
       `sdesc` varchar(40) NOT NULL,
       `rqemail` varchar(40) NOT NULL,
       `sid` int(11) NOT NULL,
       `rlsid` int(11) NOT NULL,
       `dcode` varchar(5) NOT NULL
     ) ENGINE=ARCHIVE COMMENT='relay archive';
____SQL;
$result = $this->db->getConnection()->exec($sql);
?>

This will run fine but PDO will balk with the 'unbuffered' error if you follow this with another query.

Instead do:

$sql = <<<____SQL
     CREATE TABLE IF NOT EXISTS `ticket_hist` (
       `tid` int(11) NOT NULL,
       `trqform` varchar(40) NOT NULL,
       `trsform` varchar(40) NOT NULL,
       `tgen` datetime NOT NULL,
       `tterm` datetime,
       `tstatus` tinyint(1) NOT NULL
     ) ENGINE=ARCHIVE COMMENT='ticket archive';
____SQL;
$result = $this->db->getConnection()->exec($sql);

________số 8

$sql = <<<____SQL
     CREATE TABLE IF NOT EXISTS `relay_hist` (
       `rqid` int(5) NOT NULL,
       `sdesc` varchar(40) NOT NULL,
       `rqemail` varchar(40) NOT NULL,
       `sid` int(11) NOT NULL,
       `rlsid` int(11) NOT NULL,
       `dcode` varchar(5) NOT NULL
     ) ENGINE=ARCHIVE COMMENT='relay archive';
____SQL;
$result = $this->db->getConnection()->exec($sql);
?>

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.0

Để hiểu sự khác biệt giữa MySQL, MySQLi và PDO, chúng ta phải biết về từng người trong số họ. Đây không là gì ngoài các API của PHP được sử dụng để truy cập các bảng và cơ sở dữ liệu MySQL. Các nhà phát triển có thể chọn một trong số chúng cho dự án của họ, tuy nhiên, phải biết rằng MySQL không thể được sử dụng với PHP 7 và các phiên bản mới hơn của nó. Tuy nhiên, các nhà phát triển có thể sử dụng MySQL với PHP 5, hiện không được dùng nữa. Hãy có thêm một số thông tin về từng người trong số họ

  • mysql. Đây là phần mở rộng chính được thiết kế để giúp các ứng dụng PHP gửi và nhận dữ liệu từ cơ sở dữ liệu MySQL. Tuy nhiên, việc sử dụng MySQL đã không còn được dùng nữa và bị loại bỏ kể từ PHP 7 và các phiên bản mới hơn của nó. Đây là lý do tại sao nó không được khuyến nghị cho các dự án mới và đó là lý do tại sao các tiện ích mở rộng MySQLi và PDO ngày nay được sử dụng nhiều hơn
  • MySQLi. Chữ 'i' trong MySQLi là viết tắt của Cải tiến. Do đó, đây còn được gọi là phiên bản cải tiến của MySQL. Nó có nhiều tính năng mới sẽ được đề cập sau trong bài viết
  • PDO – Đối tượng dữ liệu PHP. Ưu điểm chính của việc sử dụng PDO là nó hỗ trợ và cung cấp một phương thức truy cập thống nhất tới 11 cơ sở dữ liệu khác nhau

Cơ sở dữ liệu hỗ trợ PDO như sau

  • CUBRID
  • Máy chủ MS SQL
  • Firebird/Interbase
  • IBM
  • Informix
  • mysql

  • tiên tri
  • ODBC và DB2
  • PostgreSQL
  • SQLite
  • 4D

Tuy nhiên, PDO không cho phép sử dụng tất cả các tính năng có sẵn trong phiên bản hiện tại của máy chủ MySQL. Ví dụ: PDO không cho phép hỗ trợ nhiều câu lệnh của MySQL.  

So sánh MySQL, MySQLi và PDO

  • Kết nối với cơ sở dữ liệu
  • Xử lý lỗi
  • Tìm nạp dữ liệu
  • Hỗ trợ API
  • Bảo vệ

Kết nối với cơ sở dữ liệu

mysql. Mã MySQL để kết nối với cơ sở dữ liệu là.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.1

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.2

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.3 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.4

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.5

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.6This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.3This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.8

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.9

This example is a Zend Framework example but the theory is the same.0This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.20This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.21This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.3This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.8

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.24

MySQLi. Trong trường hợp của MySQLi, chỉ có mã một dòng. Người dùng khởi tạo một phiên bản MySQLi bằng tên người dùng, mật khẩu và tên của cơ sở dữ liệu.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.1

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.26

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.27 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.28This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.29 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.30This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.31This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.21This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.33This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.21This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.35This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.21This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.37This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.8

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.24

PDO. Trong trường hợp PDO, một đối tượng PDO mới phải được tạo.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.1

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.41

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.42 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.28This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.29 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.45This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.46This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.21

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.48This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.33____121This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.35This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.8

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.24

Một lợi thế lớn của việc sử dụng PDO là nó làm cho việc chuyển đổi dự án sang cơ sở dữ liệu khác trở nên đơn giản hơn. Do đó, điều duy nhất cần làm là thay đổi chuỗi kết nối và những truy vấn sẽ không được hỗ trợ bởi cơ sở dữ liệu mới

Xử lý lỗi. Xử lý lỗi là phát hiện và giải quyết các lỗi ứng dụng, lập trình hoặc giao tiếp. Xử lý lỗi giúp duy trì luồng thực thi chương trình bình thường, vì các lỗi trong chương trình được xử lý một cách duyên dáng, do đó làm cho chương trình chạy tốt

mysql.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.1

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.55 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.56This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.3This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.58

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.59This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.60 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.61____162This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.3This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.64

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.24

Phương pháp 'die' được sử dụng để xử lý lỗi trong MySQL nhưng nó không được coi là một cách tiếp cận tốt để xử lý lỗi. Cái này là do die đột ngột kết thúc script rồi hiện lỗi ra màn hình. Điều này có thể làm cho cơ sở dữ liệu dễ bị tin tặc

MySQLi. Việc xử lý lỗi trong MySQLi nếu dễ dàng hơn một chút. mysqli. $error (mysqli_error) trả về một chuỗi mô tả về lỗi cuối cùng.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.1

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.67 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.68This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.69This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.30

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.31This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.32This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.69This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.34

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.35

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.24

PDO. PDO có phương pháp xử lý lỗi tốt nhất trong số ba phương pháp này. Điều này là do sự sẵn có của khối thử bắt. Ngoài ra, có một số chế độ lỗi có thể được sử dụng để xử lý lỗi

  • PDO. ERRMODE_SILENT. Nó được sử dụng để kiểm tra từng kết quả và sau đó kiểm tra $db->errorInfo() để biết chi tiết lỗi
  • PDO. ERRMODE_WARNING. Cảnh báo không dừng tập lệnh. Điều này cung cấp cảnh báo thời gian chạy và lỗi không nghiêm trọng
  • PDO. ERRMODE_EXCEPTION. Nó đưa ra các ngoại lệ hiển thị lỗi do PDO đưa ra. Nó không nên ném PDOException với mã của bạn. Nó hoạt động giống như or die(mysql_error()) khi nó không bị bắt. Nhưng nó có thể bắt những PDOException này và xử lý như chúng ta muốn

Tìm nạp dữ liệu

mysql. Các vòng lặp lập trình chung như vòng lặp for hoặc while có thể được sử dụng cho mục đích đó. Giả sử có một bảng tên là 'data' trong cơ sở dữ liệu và chúng tôi muốn xuất tên người dùng từ mỗi hàng của bảng. Trong khi vòng lặp có thể được sử dụng theo cách sau để thực hiện công việc.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.1

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.55 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.39____180This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.58

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.59This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.60 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.61____185

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.86 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.87This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.55This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.8

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.90This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.91This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.92 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.93This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.55This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.95

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.31This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.97 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.92This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.99This example is a Zend Framework example but the theory is the same.00This example is a Zend Framework example but the theory is the same.01

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.35

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.24

MySQLi. MySQLi cũng sử dụng một vòng lặp cho mục đích này. Tuy nhiên, mã sẽ khác một chút.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.1

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.90____191____192 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.28This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.55This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.200

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.31This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.97 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.92This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.99This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.33This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.206This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.207This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.208

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.35

 

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.24

PDO. PDO có nhiều câu lệnh dựng sẵn giúp ích trong những trường hợp như vậy

  • Tuyên bố PDO. tìm nạp tất cả (). Nó trả về kết quả dưới dạng một mảng, chứa tất cả các hàng kết quả
  • Tuyên bố PDO. tìm nạpColumn(). Nó tìm nạp một cột từ hàng tiếp theo của tập kết quả
  • Tuyên bố PDO. tìm nạpObject(). Điều này đầu tiên tìm nạp các hàng tiếp theo và sau đó trả về nó dưới dạng một đối tượng
  • Tuyên bố PDO. setFetchMode(). Nó đặt chế độ tìm nạp mặc định cho câu lệnh

Hỗ trợ API. Khi nói đến hỗ trợ API, PDO cung cấp cách tiếp cận hướng đối tượng. MySQLi cung cấp một cách thủ tục, tương tự như MySQL. Đây là lý do tại sao các nhà phát triển đến từ nền tảng MySQL thích sử dụng MySQLi hơn. Tuy nhiên, các lập trình viên hướng đối tượng thích PDO hơn vì khả năng tương thích của nó với một số lượng lớn cơ sở dữ liệu. Do đó, các lập trình viên hướng đối tượng thích PDO hơn, trong khi các lập trình viên thủ tục thích MySQL và MySQLi hơn. Bảo vệ. Bảo mật cơ sở dữ liệu được sử dụng để bảo vệ cơ sở dữ liệu và thông tin chúng chứa khỏi tin tặc và các cuộc tấn công của chúng. Tin tặc thường sử dụng SQL injection để phá vỡ cơ sở dữ liệu. Vì vậy, an ninh từ các mũi tiêm phải được đảm bảo. Cả PDO và MySQLi đều cung cấp bảo mật SQL injection. Giả sử một hacker đang cố thực hiện một lệnh SQL injection thông qua tham số truy vấn HTTP 'firstname' bằng phương thức POST.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.211This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.99This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.213This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.214This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.215 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.216

Nếu nội dung tiêm thoát ra ngoài, nó sẽ được thêm vào truy vấn “as it is”. Do đó, nó sẽ xóa tất cả các hàng khỏi bảng người dùng. Trong PDO, thoát thủ công có sẵn để thêm bảo mật.  

php




This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.217 This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.218This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.211This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.99This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.221This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.222

This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.42This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.224This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.217This one can be a royal pain to deal with.  Never stack statements to be executed in one go.  Nobody ever mentions this possibility in all the posts I've seen dealing with this error.226

Sự khác biệt giữa PDO. quote() và mysqli_real_escape_string() là cái trước thoát khỏi chuỗi và trích dẫn, trong khi cái sau sẽ chỉ thoát khỏi chuỗi và các dấu ngoặc kép sẽ phải được thêm thủ công