Reply to Re: Object Oriented Approach to PHP programing and MySQL database

Your name:

Reply:


Posted by Marijn on 06/04/07 15:06

On Jun 4, 2:39 pm, gosha bine <stereof...@gmail.com> wrote:
> On 04.06.2007 13:59 Marijn wrote:
>
>
>
> > On Jun 4, 10:05 am, gosha bine <stereof...@gmail.com> wrote:
> >> On 03.06.2007 21:33 Marijn wrote:
>
> >>> Hello everybody,
> >>> I am new to PHP and working on extending my knowledge of OOP. The
> >>> posts in this group concerned with whether or not to use an OO
> >>> approach when programming in PHP is not what I want to discuss in this
> >>> post. Rather I would like to discuss the best way to program the
> >>> following problem:
> >>> I have a MySQL Database which for example exists of phonenumbers. The
> >>> table might look something like this.
> >>> +---+---------------+------+
> >>> |ID | PHONENUMBER | FLAGS|
> >>> +---+---------------+------+
> >>> |001| 612341234| FALSE|
> >>> +---+---------------+------+
> >>> |002| 612341235| TRUE |
> >>> +---+---------------+------+
> >>> |...| ...| FALSE|
> >>> +---+---------------+------+
> >>> |00N| 612341238| FALSE|
> >>> +---+---------------+------+
> >>> An object representation in PHP might be the object PhoneNumber. The
> >>> object PhoneNumber would be extended from a general class called
> >>> Entity. The class Entity allows for easy creation of new database
> >>> objects. Say I would like an EmailAddress object, I would simply
> >>> create the MySQL table, extend the Entity class with an EmailAddress
> >>> class and populate the SQL variables with the correct SQL statements.
> >>> Until this far everything is ok. But what if I would like an extended
> >>> version of the objects PhoneNumber or Emailaddress? Say for example
> >>> that I would like an object called MobilePhoneNumber. The only
> >>> difference with the normal PhoneNumberClass is that it is of the type
> >>> MobilePhoneNumber (usage: A function only accepting MobilePhoneNumber
> >>> Objects for sending text messages). I would like to create a MySQL
> >>> table that consists of mobilephonenumerid's and phonenumberid's.
> >>> What would be the best way, rewriting the internals of the Entity
> >>> class and just fetch the data from MySQL right away or writing new
> >>> internals for the MobilePhoneNumbers class which create a
> >>> phoneNumberObject if it does not exist?
> >>> Hope that my problem and questions are clear, if not please ask for
> >>> more info.
> >>> Thanks in advance
> >>> Marijn
> >> Hi Marijn
>
> >> your problem is clear and well-known, particularly PoEAA book discusses
> >> diverse approaches in detail (see e.g. "Single Table Inheritance" and
> >> other ORM patterns).
>
> >> --
> >> gosha bine
>
> >> extended php parser ~http://code.google.com/p/pihipi
> >> blok ~http://www.tagarga.com/blok
>
> > Thanks for your respons Gosha. Do you have the isbn # of the book? Is
> > there other (online) literature you would advise me to read? What is
> > your experience with this problem. What I'm concerned with most is
> > that if I would want to extend a class which has rewritten innerworks
> > I have to rewrite them again and again every time I extend. This would
> > probably result in more coding than less, hence a bit past it's goal.
> > While rewriting the innerworks every time might be a more optimal
> > concerning speed...
>
> > Thanks,
>
> > Marijn
>
> The official PoEAA site ishttp://www.martinfowler.com/books.html#eaa
> There's also small patterns catalog on the site.
>
> In my personal experience, I tend to use Table Gateways rather than
> diverse ORM flavors because it's much simpler and uses aggregation
> instead of inheritance.
>
> --
> gosha bine
>
> extended php parser ~http://code.google.com/p/pihipi
> blok ~http://www.tagarga.com/blok

Already ordered the book on Amazon. I was wondering if anyone could
give me a small introduction to this problem in the post. Would like
to start thinking about the problem now instead of 48 hours when the
book arrives.

Thanks Marijn

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация