This PHP class enables the use of MySQLi prepared queries.
The class provides access to fetch_object and fetch_assoc methods, enabling users to access data with ease. All results are recomputed, and no data caching is done. The setup is straightforward, and users can access the database connection setup details from the examples file.
To use the class, pass the MySQL query with ? substituted for variables, corresponding placeholder types, and variables for placeholders. Placeholders can be of type i, d, s, and b. The corresponding variable types are integer, double, string, and blob. For sending data of type blob or text, the size is limited to the size of max_allowed_packet. Variables to assign to each type should be scalars.
The class offers various methods, from inserting data to updating, deleting, and selecting multiple and single rows. For inserts, it returns the insert ID, while updates and deletes return a count of rows affected. To count rows without reading the data, users can use the prow function. The psingle function is ideal for selecting a single row and returning an object containing the data. The pbind function is excellent for selecting multiple rows and returning a handle.
In summary, MySQL Done Right is an exceptional class that offers a safe, efficient, and object-oriented mechanism for handling MySQL database development. Its numerous functions make it easier to insert, update, delete, and select data from the database. It is a must-have tool for PHP developers who want to create robust database-driven applications.
Version 0.24: N/A