On Jan 16, 2008 5:10 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On Jan 16, 2008 5:09 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
>
> > Here is an implementation:
> > http://framework.zend.com/manual/en/zend.registry.html
> >
> > Here is another:
> >
> http://www.stubbles.net/browser/trunk/src/mai
Eric Butera schreef:
On Jan 16, 2008 4:55 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
Eric Butera schreef:
On Jan 16, 2008 4:13 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
On Jan 16, 2008 3:59 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
given that dbaccess doesn't extend mysqli instantiation
On Jan 16, 2008 5:09 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> Here is an implementation:
> http://framework.zend.com/manual/en/zend.registry.html
>
> Here is another:
>
> http://www.stubbles.net/browser/trunk/src/main/php/net/stubbles/util/stubRegistry.php
>
cool; ill have a look when i get
On Jan 16, 2008 5:06 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On Jan 16, 2008 4:55 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
>
> > Eric Butera schreef:
> >
> >
> >
> >
> > > I still don't understand the obsession of a singleton in regards to a
> > > db connection. Using a registry is a much
On Jan 16, 2008 5:06 PM, Eric Butera <[EMAIL PROTECTED]> wrote:
> Also with the registry you can use lazy loading.
singleton is typically implemented with a lazy loading approach, and most
of the code samples ive seen on this thread today use a lazy loading
approach.
could you give us a more co
On Jan 16, 2008 4:55 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Eric Butera schreef:
> > I still don't understand the obsession of a singleton in regards to a
> > db connection. Using a registry is a much better practice I think.
> >
>
> I think I alluded to the registry pattern in my reply abo
On Jan 16, 2008 4:55 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Eric Butera schreef:
>
> > On Jan 16, 2008 4:13 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> >> On Jan 16, 2008 3:59 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> >>
> >>> given that dbaccess doesn't extend mysqli instantiation of db
Eric Butera schreef:
On Jan 16, 2008 4:13 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
On Jan 16, 2008 3:59 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
given that dbaccess doesn't extend mysqli instantiation of dbaccess is
completely
pointless no?
i dont know; i think using an instance of dbac
On Jan 16, 2008 4:13 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> On Jan 16, 2008 3:59 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
>
> > given that dbaccess doesn't extend mysqli instantiation of dbaccess is
> > completely
> > pointless no?
>
>
> i dont know; i think using an instance of dbaccess t
On Jan 16, 2008 3:59 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> given that dbaccess doesn't extend mysqli instantiation of dbaccess is
> completely
> pointless no?
i dont know; i think using an instance of dbaccess to control a single
instance of the
mysqli class is appropriate. personally, i
julian schreef:
you are forcing the no instantiation via abstract, instead of hiding via
private method constructor.
you want to garantee a single instance of the mysqli object - who cares
exactly how this is done. besides which the whole exercise is bogus. you
want a DB connection abstractio
you are forcing the no instantiation via abstract, instead of hiding via
private method constructor.
You change the constructor for an init function.
still the $dummy = new dbaccess (). looks like a simpler solution
Thanks for your comments
Jochem Maas wrote:
julian schreef:
H
> -Original Message-
> From: Julian [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 16, 2008 3:39 PM
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] green bean question on singleton php5
>
>
> nope... only works if I change
>
> $dummy= new dbac
On Jan 16, 2008 1:36 PM, Julian <[EMAIL PROTECTED]> wrote:
> I would like to understand what am I missing fom the concept
here are the issues i see;
you should have a private static for the instance of dbaccess
you should have a private instance variable for the instance of the mysqli
class
julian schreef:
Hi,
I am implementing this
try comparing this rewrite with your version:
abstract class dbaccess {
static $db = null;
private static function init() {
if (dbaccess::$db))
return;
dbaccess::$db = new mysqli("localhost",USER,PASSWD,DB);
if(mysqli_con
> -Original Message-
> From: Julian [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 16, 2008 3:37 PM
> To: Daniel Brown
> Cc: julian; php-general@lists.php.net
> Subject: Re: [PHP] green bean question on singleton php5
>
>
> but that forces me to imp
to all who have posted classes w/ the singleton instance as a
public static; this is not good.
the singleton instance should be stored in a private static variable.
why? because, otherwise client code can just access the value
directly, and even unset the instance; which sort of defeats the
purpos
nope... only works if I change
$dummy= new dbaccess();
and keep the rest .
Thanks.
... hope it does not repeat... got undelivered...
Eric Butera wrote:
On Jan 16, 2008 12:57 PM, julian <[EMAIL PROTECTED]> wrote:
Hi,
I am implementing this
class dbaccess{
static $db=null;
st
but that forces me to implement a large interface of functions that I
prefer to avoid...
the $dummy thing works... but I guess it is not "by the book".
I would like to understand what am I missing fom the concept
Thanks.
JCG
Daniel Brown wrote:
On Jan 16, 2008 12:57 PM, julian <[EMAIL
On Jan 16, 2008 12:57 PM, julian <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I am implementing this
[snip!]
I'm heading out to lunch, so double-check this for errors, but I
rewrote your class. You'll have to add your fetch handlers and such.
query(..); // Your query here.
?>
On Jan 16, 2008 12:57 PM, julian <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I am implementing this
>
> class dbaccess{
>static $db=null;
>static $othervar=33;
>
>private function dbaccess(){
> dbaccess::$db= new mysqli("localhost",USER,PASSWD,DB);
> if(mysqli_connect_errno()){
21 matches
Mail list logo