PHP 5 Users can use the MySQL extension,mysqli and pdo_mysql link database, but in the PHP7 to remove the MySQL extension way, (W3school is still this way of linking, embarrassing).
So, in this I just use the back two ways.
First, Mysqli link
$mysqli = new Mysqli (' 127.0.0.1 ', ' root ', ', '), if ($mysqli->connect_error) {die (' Connect error ('. $mysqli Connect_errno. ') '. $mysqli->connect_error);} echo "<p> Connection OK $mysqli->host_info </P>" echo "<p> Server $mysqli->server_info </p > ";
Second, Pdo_mysql link database
try{$pdo = new PDO ("Mysql:host=localhost", ' root ', ');} catch (Pdoexception $e) {echo "Connection fialed: $e->getmessage ()";}
Queries with cache and no cache
The query uses a cached query by default. This means that the results of the query are immediately sent from the MySQL server to PHP and then stored in the PHP parser memory. This allows extra operations like counting the number of rows, moving or looking for the current result pointer.
It also allows for further querying on the same connection and result set. The bad side of cache mode is that large result sets may require a large amount of memory that is occupied until the result set is purged or freed, which is done automatically at the end of the request. The term store result is used to represent the cache mode, and all result sets are saved immediately.
Without a cached MySQL query being executed, a resource is returned immediately, and the data is waiting for the MySQL server to be connected. This is used with less memory on the PHP side, but this time increases the load on the server.
Until all result sets are taken away from the server and no queries are sent that are built on the same connection. Queries that are not cached are also known as usage results.
As you can see from these features, the cache query is used when you only want to get a finite result set, or you know the number of rows to return the result set before reading the result set.
There is no cached query pattern used when you want to return a large amount of data. (Transferred from http://blog.csdn.net/yingzhicai/article/details/50936675)
PHP Link Database