![]() |
Review my DB class
1 Attachment(s)
I wrote a class to handle multiple databases (it currently handles mysql, mssql, sqlite) and I'd like your opinion on what can be done to improve it and such, it's very simplistic as far as database abstraction classes go.
Some examples of it's use PHP Code:
Note -- I also added a secure sql feature called ParseSql() PHP Code:
|
You just wasted a bunch of time: mysqli.
|
Quote:
Quote:
|
Sorry for the double post.
After finally taking the time to peruse your code Andres, I must say I like your method. Our style and implementation differ, but we think similarly. Good work on abstracting your database code away from the drudgery of repetition. One thing I noticed is the difference in $myDb->mssql_escape() functions. Why not have an abstract function in the parent class and override that per child class. Just one call to escape for the object, regardless of internal type. No need to have independently named escape functions. ;-)And MySQLi isn't nearly present enough in modern servers. My server with MySQL 5.0.45 and PHP 5.2.5 doesn't have it, and it's no guarantee anyone else does too. Never assume, always prepare for the worst. ^^ |
Thanks you, I plan to add more database support later on.
The reason I added the mssql was because of the lack of an escape_string() or escape_real_string() function in php (atleast...when I looked for it, and it's probably not a very good replacement at that..but it's better than nothing), it was supposed to be only internally (maybe I forgot to set it to private). |
I was also talking about delegating escaping the data to the classes themselves. That way no matter which version you've got, just call the escape function to have the database specific escape function(s) applied.
Good work on your part to write an mssql escape function. It's bad form for them not to have one. |
Updated with new goodies
1 Attachment(s)
Sorry if it's annoying asking to go through my classes but I like feedback to further myself as a programmer, anywho...
The class handles MySQL,MSSQL, SQLite, PostgreSQL, Ibase, and has a generic ODBC driver (please note, the classes don't dwelve into any of the special function provided by each of the databases, the class is only meant to retrieve data in an easy to use format) created an escapestring function which works generically on everything...the bugginess an obtrusiveness of it has not been heavily tested so any feedback is more than welcome.. PHP Code:
PHP Code:
PHP Code:
Beyond that all the variables and such have been abstracted to the VariableScope class (new) so that they may easily accessed by all three classes (DB_handle,Record, DB driver) It probably has a load of bugs and I'd be very grateful to anyone who is willing to test it out as well Also the speed or lack there of is of concern to me so it's slow for anyone that feedback is also appreciated (P.S. Salathe, your more than welcome to take a go at my code, or anyone else who feels like it too...Constructive criticisms is awesome) |
| All times are GMT. The time now is 06:02 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0