Follow me on GitHub

Abstract database class with PDO in PHP

Paris Nakita Kejser - April. Friday 16th 2021

Why use a PDO framework in PHP, when you can learn how to build your own. I will teach you to build your own PDO abstract database class with PHP. PDO its a database connecter in PHP in the same way as mysqli are. I prefer to use PDO in all so I can change database server if needed.

You will learn how you can build a abstract database class with PDO in PHP. You will learn how you can use your own abstract database class when you need to connect to your database. I will show how to connect to your MySQL database when using your own database class.

Its nothing bad to use a prebuild ORM database framework like Doctrine. But why not get the very good knowledge about it when you are building your own abstract database class. You are learning more about how PDO are working by developing your own ORM in PHP. Its a very good place to start to build your own before use a framework for a ORM.

When you finished with this PDO database class in PHP, you get the knowledge about to protect you self agents SQL injection in PHP by using bind params in PDO. You will get basic feature knowledge example fetch, fetchAll, execute. 

Then I have a little function more to your, so you can analyze your SQL query's, the function called getStatistics.