<?php/** * Test the execution efficiency of PDO and mysqli */header ("Content-type:text/html;charset=utf-8");//link database via PDO $pdo_starttime = Microtime (true); $pdo = new PDO ("Mysql:host=localhost;dbname=test", "root", "1234", Array (pdo::mysql_attr_init_ COMMAND = "SET NAMES ' UTF8 ';")); for ($i =1; $i <=100; $i + +) {$title = "PDO title". $i; $content = "PDO content" $i; $addtime = time (); $user _id = $i; $pdo _sql = "INSERT in To ' article ' (' title ', ' content ', ' addtime ', ' user_id ') VALUES (: title,:content,:addtime,:user_id) "; $sth = $pdo Prepare ($pdo _sql), $sth->bindparam (': Title ', $title), $sth->bindparam (': Content ', $content); $sth Bindparam (': Addtime ', $addtime); $sth->bindparam (': user_id ', $user _id); $sth->execute ();} $pdo _endtime = Microtime (True), $pdo _time = $pdo _endtime-$pdo _starttime;echo $pdo _time;echo "Test results: In fact, after many tests, PDO and mysqli the implementation of the same efficiency.
Use Mysqli and PDO extensions in PHP to test the execution efficiency of your MySQL database.