MySQL Connect

MySQL Connect


For Connecting databse with php your local server you can use xampp server :

Learn how to install Xampp server in local computer to check this link https://www.webdesigninghouse.com/tutorials/php-installation-with-examples

 

PHP Connect to MySQL :

Since PHP 5.5, mysql_connect() extension is deprecated. Now it is recommended to use one of the 2 alternatives.

  • MySQLi extension (the "i" stands for improved)
  • PDO (PHP Data Objects)

Earlier versions of PHP used the MySQL extension. However, this extension was deprecated in 2012.

Which one should we use MySQLi or PDO ?

  • PDO will work with 12 different database systems, whereas MySQLi will only work with MySQL databases.
  • So, if you have to shift your project to use alternative database, PDO makes the process easy. You only have to change the connection string and a few queries. With MySQLi, you will need to rewrite the complete code — queries included.
  • Both are object-oriented, but MySQLi also offers a procedural API.

Connection to MySQL using MySQLi

     It can be done in two ways:

MySQLi Object-Oriented

MySQLi Procedural : 

Connection to MySQL using PDO