Development Information

April 21, 2012

Database Class v 3.0.0 in development

Filed under: Database Class Information,Updates — judda @ 6:44 pm

Hey All,

So I’ve finally decided to take on my overhaul of the database object that I made a few years ago now (my how time flies). I just noticed that I posted the original idea back in November 2010 (so much for doing it within the next few weeks).

Essentially this change will affect several things about the database object. The main one being the syntax used to bind the parameters to the query. You will be able to write queries as follows:


$query='SELECT `Username` FROM `Users` WHERE `Username` LIKE {0:s} OR `FullName` LIKE {0:s}';
$db->query($query, 'foo');
// OR
$query='SELECT `Username` FROM `Users` WHERE `UserId` = {u}';
$db->query($query, 'foo');

That said, I am also building into it a “classic” mode where you can use the %s and stuff as you did in the old versions.

While I am at it, I was thinking about renaming some of the type strings. The thing is with this renaming it would also affect the ‘classic’ mode. So I want to know what you guys think about it.

Below is a list of what it currently is, and what I’m thinking of changing it to, or if they are being removed.

* %u – unsigned integer – ud
* %d – signed integer – d
* %p – decimal number – f
* %b – binary files – b
* %h – string (HTML permitted) – s
* %s – string (no HTML permitted) – es
* %l – list of values or an array – l

* unsigned decimal number – f

Possible Expansion:
* list of values or an array – l – should there be type checking enabled on these? (i.e. lp would be a list of decimal numbers, ls would be a list of strings, etc.)

* %i – IP Address – shouldn’t be storing IP addresses as strings, and it was very inflexible for IPv6
* %f – field

Another thing I could do, is make these keys also configurable so that you can get a ‘true classic’ mode by just switching the type codes back to what they originally were (except for the 2 which I was planning on removing). Would this make the upgrade easier?

While I am in here ripping out the guts of it and rebuilding it, was there anything in it that really annoyed you when using it? If yes, what was it, maybe I can improve it this time around?

There are a few simple things that I’ll be changing as well but I’ll still be leaving it so you can use it the same way as before (but with deprecation notices) so there won’t be much re-work there.

Please let me know what you think by either posting a comment on here, or sending me an email through the contact page.

Powered by WordPress