One php Tutorial every day. today I want to summarize several methods for connecting to the mysql database & amp; rdquo, I just learned something I just learned after setting up the php environment a year ago, but after studying it for so long, I was so silly to follow the php Tutorial manual.
One php Tutorial every day. today, I suddenly want to summarize several methods of "connecting to mysql database", something I just learned after setting up the php environment a year ago, but after learning for such a long time, it was silly to take photos.Php TutorialThis is the simplest and most common mysql connection method!
1. the simplest way
2. object-oriented mysqli (detailed tutorial)
3. pdo connection to mysql (detailed tutorial)
Query ('select * from user') as $ row) {print_r ($ row) ;}$ db = null; // Close the database} catch (PDOException $ e) {echo $ e-> getMessage () ;}?>
4. connecting to mysql using ADODB (detailed tutorial)
connect('localhost','root','','test');$conn->Execute("set names utf8");$res = $conn->Execute("select * from user");if (!$res){echo $conn->ErrorMsg();}else{var_dump($res);}?>