Skeleton Framework

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
VirtuosiMedia
Forum Contributor
Posts: 133
Joined: Thu Jun 12, 2008 6:16 pm

Re: Skeleton Framework

Post by VirtuosiMedia »

thinsoldier wrote: @VirtuosiMedia
I'd really like to see the source of your form class and database class. How do you customize the html surrounding your classes (tables/divs/fieldsets etc)?
The source code still needs some refining, but I'll probably release the framework sometime this summer and I'll post on here when I do. For the forms class, all it really does is build each element for the form in order. If you need to include something else into the form, I use 3 different methods: append($data), startTag($tag, array $attributes), and endTag($tag). The first will add whatever data you give it in the same order, the last two are good if you need to wrap parts of the form.

The database class is fairly simple in that it constructs the query by concatenating the different parameters you pass in to the methods. It uses PDO with bound parameters to execute the queries, so theoretically everything is injection safe. The reason I pass in the different parts of the query into various methods is because I eventually want to provide an abstraction layer for different flavors of SQL, the idea being that you write your code once, the details are taken care of by the class, and it works with multiple database types, with the only change being made in a configuration file. The downside is that it limits what types of data manipulation can be done because not all DBMS's support the same features and not everything can be emulated across all types. I haven't had a chance to create classes for anything but MySQL yet, but so far the MySQL class seems to be working fine.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Skeleton Framework

Post by josh »

VirtuosiMedia wrote:What would say is the best way for planning and creating a class based on your experiences?
I usually design the relationships between the classes & modules, rather then focusing my design efforts "inwards", I'll stub out the design of a class and implement it only if I have to, I try to use TDD to "design" the classes themselves for me. Implementation following the design of the API not visa versa
Post Reply