Home >Backend Development >PHP Tutorial >A brief discussion on the difference between mysql and mysqli in PHP_PHP Tutorial

A brief discussion on the difference between mysql and mysqli in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:06:52745browse

First of all, both functions are used to process DB.
First of all, mysqli connection is a permanent connection, while mysql is a non-permanent connection. What does it mean? Whenever the mysql connection is used for the second time, a new process will be reopened, while mysqli only uses the same process, which can greatly reduce the pressure on the server side.
Secondly, mysqli encapsulates some advanced operations such as transactions, and also encapsulates many available methods in the DB operation process.
The place where it is most widely used is mysqli transactions.
For example:

Copy the code The code is as follows:

$mysqli = new mysqli('localhost','root','','DB_Lib2Test');
$mysqli->autocommit(false);//Start things
$mysqli->query($sql1);
$mysqli->query($sql2);
if(!$mysqli->errno){
$mysqli->commit();
echo 'ok';
}else{
echo 'err';
$mysqli->rollback();
}
 

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327585.htmlTechArticleFirst of all, both functions are used to process DB. First of all, mysqli connection is a permanent connection, while mysql is a non-permanent connection. What does it mean? Whenever the mysql connection is used for the second time, it will...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn