phpgroupware-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SV: [Phpgroupware-developers] php5 vs php4: db-handling


From: Sigurd Nes
Subject: SV: [Phpgroupware-developers] php5 vs php4: db-handling
Date: Sun, 29 Jan 2006 00:03:37 +0100 (CET)

> From: Earnie Boyd address@hidden
> Sent: 2006-01-27 13:41:21 CET
> To: address@hidden
> Subject: Re: [Phpgroupware-developers] php5 vs php4: db-handling
> 
> Quoting Sigurd Nes <address@hidden>:
> 
> > It seems like php5 differ from php4 when one needs a second db-object 
> > inside a db->next_record()-loop.
> >
> > In php4 one can do like this:
> >
> > $this->db   = $GLOBALS['phpgw']->db;
> >
> > $this->db2  = $this->db;
> >
> >
> > While for php5 one has to alter to:
> >
> > $this->db            = $GLOBALS['phpgw']->db;
> > $this->db2           = CreateObject('phpgwapi.db');
> > $this->db2->Host     = $GLOBALS['phpgw_info']['server']['db_host'];
> > $this->db2->Type     = $GLOBALS['phpgw_info']['server']['db_type'];
> > $this->db2->Database = $GLOBALS['phpgw_info']['server']['db_name'];
> > $this->db2->User     = $GLOBALS['phpgw_info']['server']['db_user'];
> > $this->db2->Password = $GLOBALS['phpgw_info']['server']['db_pass'];
> >
> > The db initialization could be moved to a function to enable this:
> > $this->db2 = $GLOBALS['phpgw']->new_db;
> >
> > Any thoughts?
> >
> 
> <excerpt cite="http://www.zend.com/php5/andi-book-excerpt.php";>
> In PHP 5, the infrastructure of the object model was rewritten to work 
> with object handles. Unless you explicitly clone an object by using the 
> clone  keyword you will never create behind the scene duplicates of 
> your objects. In PHP 5, there is neither a need to pass objects by 
> reference nor assigning them by reference. </excerpt>
> 
> HTH,
> Earnie Boyd
> 
Could you make an example of the db-class, and relate it to how it is used 
trough out phpgroupware?
I have now in the app 'property' switched to initialize the db-classes with a 
function new_db() - and it works fine with both php4 and php5. (But of course - 
ther could be smarter ways...)

Regards

Sigurd

reply via email to

[Prev in Thread] Current Thread [Next in Thread]