# Extending internal classes like mysqli

- Thread: https://externals.io/message/9995
- Original archive: https://news-web.php.net/php.internals/9995
- Started by Bert Slagter on 2004-05-21T12:52:08+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9995 — Bert Slagter — 2004-05-21T12:52:08+00:00

URL: https://externals.io/message/9995#9995

Good afternoon!

Could anyone explain what we're supposed to do with internal classes 
like the mysqli class.

In an article on Zend.com 
(http://www.zend.com/php5/articles/php5-mysqli.php) the fact that the 
object oriented interface can be extended is brought as a major feature. 
But it seems that it's impossible to extend the mysqli class, see my bug 
at http://bugs.php.net/bug.php?id=28430.

What I want is this. I need some custom logging for my database layer. 
So I want to extend the mysqli class and overwrite one or two methods 
and add some custom methods.

Shouldn't I be able to just do:

class foo extends mysqli
{
}

$foo = new foo();

Right now this doesn't work - the variable $foo->thread_id isn't 
available for example.

Is this intended behaviour?

Bert Slagter

---

## #9999 — Marcus Boerger — 2004-05-21T16:23:07+00:00

URL: https://externals.io/message/9995#9999 · In reply to: #9995

Hello Bert,

some of the internal classas cannot be extended and unfortunatley they are
not marked as 'final' right now. For you that means you need to extend it
by a proxy class that reimplements the original class protocol and uses
the original class as a property.

Friday, May 21, 2004, 2:52:08 PM, you wrote:

> Good afternoon!

> Could anyone explain what we're supposed to do with internal classes 
> like the mysqli class.

> In an article on Zend.com 
> (http://www.zend.com/php5/articles/php5-mysqli.php) the fact that the 
> object oriented interface can be extended is brought as a major feature. 
> But it seems that it's impossible to extend the mysqli class, see my bug 
> at http://bugs.php.net/bug.php?id=28430.

> What I want is this. I need some custom logging for my database layer. 
> So I want to extend the mysqli class and overwrite one or two methods 
> and add some custom methods.

> Shouldn't I be able to just do:

> class foo extends mysqli
> {
> }

> $foo = new foo();

> Right now this doesn't work - the variable $foo->thread_id isn't 
> available for example.

> Is this intended behaviour?

> Bert Slagter




-- 
Best regards,
 Marcus                            mailto:helly@php.net

---

## #10016 — Bert Slagter — 2004-05-21T21:37:38+00:00

URL: https://externals.io/message/9995#10016 · In reply to: #9999

Hi Marcus,

Thanks for your clear answer :). What are the future plans concerning 
this issue? Will I be able to just extend this class as I want? For 
which version is that planned? The answers to these questions heavily 
influence design choices I have to make now.

Oh, and I'm curious why the article on Zend.com mentions that 
extendability is a key feature of mysqli. Even though it cannot be 
extended.. :)

Bert


Marcus Boerger wrote:

> Hello Bert,
> 
> some of the internal classas cannot be extended and unfortunatley they are
> not marked as 'final' right now. For you that means you need to extend it
> by a proxy class that reimplements the original class protocol and uses
> the original class as a property.
> 
> Friday, May 21, 2004, 2:52:08 PM, you wrote:
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]
> 
> 
> > […]

---

## #10091 — Bert Slagter — 2004-05-26T00:47:49+00:00

URL: https://externals.io/message/9995#10091 · In reply to: #10016

The last few days I've been working with mysqli, and every hour I work 
with it, my worry grows. It's far from finished: no good documentation 
in the ext dir, below average online documentation, partly implemented 
object orientation (no destructor, no extensions allowed, etc).

Is there any chance this will get better soon? I heard on the PHP 
Conference in Amsterdam that both PHP 5 and MySQL 4.1 are expected to be 
final somewhere this summer, so I'd expect some improvement in this 
extension soon ;)

Bert

Bert Slagter wrote:
> Hi Marcus,
> 
> Thanks for your clear answer :). What are the future plans concerning 
> this issue? Will I be able to just extend this class as I want? For 
> which version is that planned? The answers to these questions heavily 
> influence design choices I have to make now.
> 
> Oh, and I'm curious why the article on Zend.com mentions that 
> extendability is a key feature of mysqli. Even though it cannot be 
> extended.. :)
> 
> Bert
> 
> 
> Marcus Boerger wrote:
> 
> > […]

---

## #10092 — George Schlossnagle — 2004-05-26T01:01:32+00:00

URL: https://externals.io/message/9995#10092 · In reply to: #10091

> The last few days I've been working with mysqli, and every hour I work 
> with it, my worry grows. It's far from finished: no good documentation 
> in the ext dir, below average online documentation, partly implemented 
> object orientation (no destructor, no extensions allowed, etc).
>
> Is there any chance this will get better soon? I heard on the PHP 
> Conference in Amsterdam that both PHP 5 and MySQL 4.1 are expected to 
> be final somewhere this summer, so I'd expect some improvement in this 
> extension soon ;)

Congrats!  I hear we're accepting patches now.

George
