From the course: PHP: Object-Oriented Programming with Databases

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Connect to the database

Connect to the database

- [Instructor] Now that we have our database credentials installed, let's see how we connect to the database using object-oriented programming. First, let's begin by reviewing the procedural version which we've used to connect to the databases with PHP up until now. To do that, we used a function called mysqli_connect and we passed in several arguments for the server, the user, the password, and the database name. That function returns back a database handle which can then be used to connect to the database in the future. It opens up a connection and we're able to then work with that connection going forward. So for example if we want to query the database, we can call another function mysqli_query. We pass in that database handle as well as the SQL that we want to query. This is a procedural style. There's no object-oriented programming here, and we're just calling basic PHP functions. The mysqli adapter also has…

Contents