Re: [PHP] Extending a class with a static constructur (like PEAR::DB)

2006-03-10 Thread Andreas Korthaus
Chris wrote: You'll need to: $dbtoy = new DBToyExt(); $dbtoy->connect() $dbtoy->testext('testing'); But you cannot do: $dbtoy = new DBToyExt(); $dbtoy->connect() $dbtoy->testext('testing'); $result = $dbtoy->query('SELECT...'); //[...] You have to do something like this: $dbtoy =

Re: [PHP] Extending a class with a static constructur (like PEAR::DB)

2006-03-10 Thread Andreas Korthaus
[EMAIL PROTECTED] wrote: Ahhh! I'd kept thinking what connect() returned was a db object, but it does look like it returns varying objects depending on which database you're using. correct Maybe I'd want to extend DB_common instead of DB_mysql, so that the methods would be inhereted by an

Re: [PHP] Extending a class with a static constructur (like PEAR::DB)

2006-03-09 Thread weston
> > So... I'm trying to extend PEAR::DB. It'd be great to keep everything it > > offers and just add a few more perhaps unconventional functions. > > > > $dte = DBToyExt::connect("mysql://weston_tssa:[EMAIL > > PROTECTED]/weston_tssa"); > > > > DB::connect() is actually a factory call. So

Re: [PHP] Extending a class with a static constructur (like PEAR::DB)

2006-03-09 Thread Chris
[EMAIL PROTECTED] wrote: Weston wrote: $dte = DBToyExt::connect("mysql://weston_tssa:[EMAIL PROTECTED]/weston_tssa"); $dte->testext('testing'); $dte->testext($dte->moo); $dte->testext($dte->bar); >>> $dte will only have the return value of DBToyExt::connect() - it won't allow you to access

Re: [PHP] Extending a class with a static constructur (like PEAR::DB)

2006-03-09 Thread weston
Weston wrote: > > $dte = DBToyExt::connect("mysql://weston_tssa:[EMAIL > > PROTECTED]/weston_tssa"); > > > > $dte->testext('testing'); > > $dte->testext($dte->moo); > > $dte->testext($dte->bar); On Fri, Mar 10, 2006 at 10:43:02AM +1100, Chris wrote: > $dte will only have the return value of

Re: [PHP] Extending a class with a static constructur (like PEAR::DB)

2006-03-09 Thread Chris
[EMAIL PROTECTED] wrote: So... I'm trying to extend PEAR::DB. It'd be great to keep everything it offers and just add a few more perhaps unconventional functions. Intuitively, it seemed like this approach might work: testext('testing'); $dte->testext($dte->moo); $dte->testext($dte->bar

Re: [PHP] extending a class using includes not working

2005-05-26 Thread Brent Baisley
Is the include in your class 2 file the very first line, before you start declaring your class 2 classes? The class 1 file has to be loaded before you start extending it, obviously, but just checking. The other problem may be with your paths. Wherever your template file is located is where is

Re: [PHP] extending a class using includes not working

2005-05-26 Thread Jochem Maas
Charles Kline wrote: On May 25, 2005, at 7:53 PM, Richard Lynch wrote: On Wed, May 25, 2005 11:30 am, Charles Kline said: i have 2 class files. say for example. class 1 class 2 extends class 1 class 2 uses include_once("firstclass.php") include, require, etal are not functions exactly.

Re: [PHP] extending a class using includes not working

2005-05-25 Thread Charles Kline
On May 25, 2005, at 7:53 PM, Richard Lynch wrote: On Wed, May 25, 2005 11:30 am, Charles Kline said: i have 2 class files. say for example. class 1 class 2 extends class 1 class 2 uses include_once("firstclass.php") then i use include_once ("secondclass.php") in my template. this does no

Re: [PHP] extending a class using includes not working

2005-05-25 Thread Richard Lynch
On Wed, May 25, 2005 11:30 am, Charles Kline said: > i have 2 class files. say for example. > > class 1 > > class 2 extends class 1 > > class 2 uses include_once("firstclass.php") > > then i use include_once ("secondclass.php") in my template. this does > not work. to get it to work, i must put bo

Re: [PHP] Extending a Class

2005-01-24 Thread Matthew Weier O'Phinney
* Jason Barnett <[EMAIL PROTECTED]>: > Matthew Weier O'Phinney wrote: > > * Phillip S. Baker <[EMAIL PROTECTED]>: > ... > > The object *instance* only gets to access the overridden method (assuming > > it's an instance of the child class): > > > > $instance->someMethod(); > > > > This is 100%

Re: [PHP] Extending a Class

2005-01-24 Thread Jason Barnett
Matthew Weier O'Phinney wrote: * Phillip S. Baker <[EMAIL PROTECTED]>: ... The object *instance* only gets to access the overridden method (assuming it's an instance of the child class): $instance->someMethod(); This is 100% correct, but just to clarify: it is possible to do something like thi

Re: [PHP] Extending a Class

2005-01-22 Thread Matthew Weier O'Phinney
* Phillip S. Baker <[EMAIL PROTECTED]>: > Thank you, > > This makes allot of sense. > However one last question about this. > > If I access the overrided function from the child class do I access it by. > > $instanceofchildclass->parent::someMethod(); > > OR would I still simply just call it > > $i

Re: [PHP] Extending a Class

2005-01-21 Thread Phillip S. Baker
Thank you, This makes allot of sense. However one last question about this. If I access the overrided function from the child class do I access it by. $instanceofchildclass->parent::someMethod(); OR would I still simply just call it $instanceofchildclass->someMethod(); And it would get to use

Re: [PHP] Extending a Class

2005-01-21 Thread Jason Barnett
Brent Baisley wrote: You're absolutely correct. I was debating on whether to get into inheritance and overloading. I just settled on what PEAR tends to use rather than go into more detail. Are you referring to the PEAR::isError (and similar function calls) that you see all over the place in PEAR

[PHP] oo arcitecture (Re: [PHP] Extending a Class)

2005-01-21 Thread Ben Edwards
Your email prompted me to think about architecture. What I have is;_ a database class which is the only class with direct access to the database. a table class, which is passed the database class on instantiation. a presenter class which is passed the table class during instantiation. This m

Re: [PHP] Extending a Class

2005-01-21 Thread Brent Baisley
You're absolutely correct. I was debating on whether to get into inheritance and overloading. I just settled on what PEAR tends to use rather than go into more detail. Thanks for clarifying. On Jan 21, 2005, at 11:18 AM, Matthew Weier O'Phinney wrote: * Brent Baisley <[EMAIL PROTECTED]> : You've

Re: [PHP] Extending a Class

2005-01-21 Thread Matthew Weier O'Phinney
* Brent Baisley <[EMAIL PROTECTED]> : > You've got most of it. Just adding "extends MySQL" to your page result > class will allow you to access all function in the MySQL class. I > usually reference functions in the parent class like this: > parent::FunctionName() This is a bad practice when inh

Re: [PHP] Extending a Class

2005-01-21 Thread Brent Baisley
You've got most of it. Just adding "extends MySQL" to your page result class will allow you to access all function in the MySQL class. I usually reference functions in the parent class like this: parent::FunctionName() You still reference functions in the current class using $this->, that way y

Re: [PHP] extending a class?

2002-02-26 Thread Nick Wilson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then S.Murali Krishna declared > > Hi > Instead of extending the class you can create a language object > inside 'form' class and refer it for all your stuffs regardless of > language. > > class form > { > function form($lang) >

Re: [PHP] extending a class?

2002-02-26 Thread Nick Wilson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 * and then Simon Willison declared > Another different of doing the same kind of thing would be to use an > "object factory" as seen in the PEAR DB abstraction layer. This works by > having a static class method (i.e a method that can be called

Re: [PHP] extending a class?

2002-02-26 Thread S.Murali Krishna
Hi Instead of extending the class you can create a language object inside 'form' class and refer it for all your stuffs regardless of language. class form { function form($lang) { if($lang == "dk") { $this->lang = new dk(); } else if ($lang == "en") { $this->lang = ne

Re: [PHP] extending a class?

2002-02-26 Thread Simon Willison
Nick Wilson wrote: >So I was thinking: > >$form=new form('dk') > >Would extend the class to include all the dk language routines and > >$form=new form('en') > >Would do likewise for english. > You can do this with encapsulation. Your "form" object would actually be a wrapper around an encapsulat