| Andrew Darby 2006-06-17, 8:04 am |
| Hello, all. I have a sort of theoretical/sort of dumb question about
PHP classes, which I haven't really worked with and don't entirely
understand the purpose of, so here goes:
Say i want to handle the add or update or delete of an item to a MySQL
db, and instead of having three functions (function addItem, function
updateItem, function deleteItem), it seems I could:
a) have one function (modifyItem) with some sort of attribute saying
which type it is, and then if/else through to the appropriate type of
operation based on this flag, i.e.,
modifyItem($array_of_data, 'update') chooses the update switch
b) have a modifyItem class, with the three possible functions inside
c) stick with my three original functions
Is b) the sort of thing you might use a class for, or do I
misunderstand? If not, what would be some "classic" uses of classes
in our php/mysql world?
(I've looked at the manual, php cookbook, etc., I'm just trying to get
a very general sense of what sorts of situations are best handled by
classes.)
Thanks for any thoughts,
Andrew
|