Get the App
SLTechnology News&Howtos  ›  Database  › 

Develop your own framework-- (2) encapsulation of database tool classes

Shulou Source: shulou.com Published: 2022-06-01 09:03:09 09月30日 Update

In order to separate the content of the framework from the data, we encapsulate the commonly used classes into a utility class, and when these methods are used, the encapsulated class is called, which can greatly improve the reusability of the code.

First of all, encapsulate the database-related operations, in order to standardize the encapsulation, we create an interface for the database to implement the methods in the interface, and the database uses PDO extensions to access the data.

Database interface class

I_DAO.interface.php

Tags: Data query method statement information database object error field encapsulation tool instance interface result output function package quotation mark quantity escape Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Docker MySQL Redmi macOS