Home>Article>Backend Development> What does php MySQLi mean?
php MySQLi means: 1. mysqli is an enhanced version of the mysql system function, which is more stable, efficient and safe; 2. mysqli and mysql are both function sets in PHP; 3. mysqli is a permanent connection function , mysqli runs multiple times using the same connection process to reduce server overhead.
php MySQLi means:
1. The concept of mysqli:
(1), mysql and mysqli are both PHP function sets and have little connection with the mysql database.
(2). After the php5 version, the function function of mysqli has been added. In a sense, it is an enhanced version of the mysql system function, which is more stable, efficient and safe, and is similar tomysql_query ()
corresponds tomysqli_query()
, which is object-oriented and uses objects to operate and drive the mysql database.
(3) Before the php5 version, PHP's mysql function was generally used to drive the mysql database, such as the mysql_query() function, which is process-oriented.
2. The difference between mysql and mysqli:
(1) Mysql is a non-persistent connection function. Mysql will open a connection process every time it is connected.
(2). Mysqli is a permanent connection function. Running mysqli multiple times will use the same connection process, thus reducing server overhead. mysqli encapsulates some advanced operations such as transactions, and also encapsulates many available methods in the DB operation process.
3. Mysqli usage reference:
$conn = new mysqli('localhost', 'user', 'password','data_base'); //要使用new操作符,最后一个参数是直接指定数据库 //假如构造时候不指定,那下一句需要$conn -> select_db('data_base')实现 $result = $conn -> query( 'select * from data_base' ); $row = $result -> fetch_row(); //取一行数据 echo row[0]; //输出第一个字段的值 使用new mysqli('localhost', usenamer', 'password', 'databasename');会报错,提示如下: Fatal error: Class 'mysqli' not found in ...
Usually mysqli is not enabled because the mysqli class is not enabled by default. It needs to be changed under winphp .ini
, remove the [;] beforephp_mysqli.dll
, and mysqli must be compiled into it under Linux.
Related learning recommendations:PHP programming from entry to proficiency
The above is the detailed content of What does php MySQLi mean?. For more information, please follow other related articles on the PHP Chinese website!