X

A Class in PHP for MySQL Connections

In this article we will see how to structure a simple class that allows us in a few steps to access the MySQL database and retrieve data, of course, the class should be improved and adapted, but to demonstrate the basics of the implementation is excellent in my view.

 

The class is called CMySQL and has three private properties that serve to keep in memory the values of the connection to the database, with the constructor we open the connection and choose the database, with OpenRowset open the query to the table with MoveNext and go to the next record, with GetData recover data from the row.
By implementing a class with connections to the MySQL database saves repetitive tasks and work with higher-level functions, without recourse to the basic functions of the library.

Categories: PHP
giampy107:
X

Cookies Policy

We use cookies to personalize content and ads, provide social media features and analyze our traffic. We also share information about your use of our site with our web analytics, advertising and social media partners who may combine it with other information you have provided to them or that they have collected based on your use of theirs. services.

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings