Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

simulating object upcasting to an interface in PHP 4

 
   Database Forums (Home) -> PHP RSS
Next:  One liner for finding a file  
Author Message
lawrence4

External


Since: Jul 03, 2003
Posts: 18



(Msg. 1) Posted: Wed Aug 11, 2004 9:45 am
Post subject: simulating object upcasting to an interface in PHP 4
Archived from groups: comp>lang>php (more info?)

In Java one is supposed to upcast an object to its interface whenever
appropriate:

MyInterface customers = new MySpecificClass();

The idea is that if later one wants to change the specific
implementation one only has to change a few lines, possibly just the
one line above. Thus the code becomes more flexible.

Is it right to say that there is no way to do this in PHP? I've taken
to simulating the same by using one object as a mask that sets and
then uses another object:

myMaskObj = new MaskDatabase();

myMaskObj->setDbObj("DatabaseObject");
myMaskObj->query("SELECT * FROM content WHERE type='comments'");

MaskDatabase has a method called "query" which simply passes the query
along to DatabaseObject which also has a method called query.

Other ideas?

 >> Stay informed about: simulating object upcasting to an interface in PHP 4 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Concerns/questions about file upload interface using PHP/s.. - I want users to be able to login to their directory via .htaccess on an Apache server to upload their files with sizes of 30-60mb for a single file. I want to make it as easy as possible for the users. I have seen web pages interfaces like this before,....

how to use object as array like in simplexml - Hi, I am new to PHP, and I'm trying to implement something similar to SimpleXML. The following code demonstrates an example of what I'm trying to achieve: <?php $xmlstr = <<<XML <asdf> <foo att="val1">bar1</foo> ...

Does PHP have an equivalent of JavaScript's prototype obje.. - Basically, I want to add default methods to the PHP string object so that I can do something like: $stringvar = "hello"; $stringvar -> append(" world"); // where append is some kind of prototyped function i define echo $stringva...

PHP5 Object and Class Errors - I've been doing some level of PHP programming for many years now, and have in the past few months started implementing lots of the core PHP5 features into a new project, when I noticed some interesting issues with objects and classes. I'm having some..

Problem with object cloning in PHP5 - When I clone an istance of System class I want to clone all SubSystem istances in $subsystems array too, so I tryed with this code: class System { public $name; public $subsystems = array(); function __construct($name){ $this->nam...
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]