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.

This entry was posted in PHP. Bookmark the permalink.