For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2006 > Question about Classes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Question about Classes
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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com