Friday, December 5, 2008

DB.class

I created this class to help my self save some time writing code to access a MySQL DB.
It contains all the esential methods to connect to the DB, execute a SELECT, execute a DML (insert, update, delete) and retrieve relevant information about the last query executed (result, number of affected rows, last id inserted).

The idea is to extend this class when you want to access a table of your DB and reuse the methods without re-typing all the lines of code to connect to the DB, fetch the results, evaluate if errors were returned, etc.

///////Put code of the class here



All your now code is reduced to:
- Create a class that extends this one.
- Write your query (simple string).
- Call one of the methods of the DB class that already handles everything else (connection, execution, fetching results, building returning message of OK or ERROR).


//Put example of how to use it here


I hope you find this class useful. Any comments are welcome.

No comments:

Post a Comment