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

Your name:

Reply:


Posted by gosha bine on 06/04/07 08:05

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

[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

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