Re: DB_DataObject
| From: | Justin Patrin | Date: | Sun, 03 Oct 2004 18:57:22 +0000 |
| Subject: | Re: DB_DataObject | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14739@lists.php.net to get a copy of this message | ||
On Sat, 2 Oct 2004 18:52:55 +1000, Craig Ambrose
<craiga@webelements.com.au> wrote:
>
> Hi, I'm trying to get my head around DB_DataObject. I've implemented the
> sample code in the documentation, and it works very nicelly indeed. What I'm
> curious about is, when exactly does the database connection happen?
>
It makes one connection per DB.
> Does it open a new connection each time an sql statement is required (such as
> when call $person->get()). If so, how is this for efficiency? Previously my
> app was opening a single connection for all the queries required for that php
> process.
>
> Secondly, is there any way to make it use a specific pear DB object? I'd like
> to be able to use these DB_DataObject(s) in conjuction with unit tests, and
> it might be nice to be able to pass in a 'mock' database object.
>
I'm not sure about this, bu you could always just make your own DB
driver and change the DSN to use it:
mock://user:pass@host/db
--
paperCrane --Justin Patrin--